





<!DOCTYPE html>
<html class="writer-html5" lang="zh-CN" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>tvm.tir &mdash; tvm 0.8.dev1982 文档</title>
  

  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/tlcpack_theme.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../_static/tvm-logo-square.png"/>
  

  
  
  
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/translations.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <script type="text/javascript" src="../../../_static/js/tlcpack_theme.js"></script>
    <link rel="index" title="索引" href="../../../genindex.html" />
    <link rel="search" title="搜索" href="../../../search.html" />
    <link rel="next" title="tvm.te" href="te.html" />
    <link rel="prev" title="tvm.target" href="target.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    
<header class="header">
    <div class="innercontainer">
      <div class="headerInner d-flex justify-content-between align-items-center">
          <div class="headerLogo">
               <a href="https://tvm.apache.org/"><img src=https://tvm.apache.org/assets/images/logo.svg alt="logo"></a>
          </div>

          <div id="headMenu" class="headerNav">
            <button type="button" id="closeHeadMenu" class="navCloseBtn"><img src="../../../_static/img/close-icon.svg" alt="Close"></button>
             <ul class="nav">
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/community>Community</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/download>Download</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/vta>VTA</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/blog>Blog</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/docs>Docs</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmconf.org>Conference</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://github.com/apache/tvm/>Github</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmchinese.github.io/declaration_zh_CN.html>About-Translators</a>
                </li>
             </ul>
               <div class="responsivetlcdropdown">
                 <button type="button" class="btn-link">
                   ASF
                 </button>
                 <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                 </ul>
               </div>
          </div>
            <div class="responsiveMenuIcon">
              <button type="button" id="menuBtn" class="btn-menu"><img src="../../../_static/img/menu-icon.svg" alt="Menu Icon"></button>
            </div>

            <div class="tlcDropdown">
              <div class="dropdown">
                <button type="button" class="btn-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  ASF
                </button>
                <div class="dropdown-menu dropdown-menu-right">
                  <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                  </ul>
                </div>
              </div>
          </div>
       </div>
    </div>
 </header>
 
    <nav data-toggle="wy-nav-shift" class="wy-nav-side fixed">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../index.html">
          

          
            
            <img src="../../../_static/tvm-logo-small.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
                <div class="version">
                  0.8.dev1982
                </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption" role="heading"><span class="caption-text">如何开始</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../install/index.html">安装 TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../contribute/index.html">贡献者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">用户引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../tutorial/index.html">User Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../how_to/index.html">How To Guides</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">开发者引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/tutorial/index.html">Developer Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/how_to/how_to.html">开发者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">架构指南</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../arch/index.html">Design and Architecture</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">主题引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../topic/microtvm/index.html">microTVM：裸机使用TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../topic/vta/index.html">VTA: Versatile Tensor Accelerator</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">参考指南</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../langref/index.html">语言参考</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Python API</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="runtime.html">tvm.runtime</a></li>
<li class="toctree-l2"><a class="reference internal" href="ndarray.html">tvm.runtime.ndarray</a></li>
<li class="toctree-l2"><a class="reference internal" href="error.html">tvm.error</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html">tvm.ir</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html#module-tvm.instrument">tvm.instrument</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html#module-tvm.transform">tvm.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="target.html">tvm.target</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">tvm.tir</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-tvm.tir.transform">tvm.tir.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="#tvm-tir-analysis">tvm.tir.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-tvm.tir.stmt_functor">tvm.tir.stmt_functor</a></li>
<li class="toctree-l2"><a class="reference internal" href="te.html">tvm.te</a></li>
<li class="toctree-l2"><a class="reference internal" href="te.html#module-tvm.te.hybrid">tvm.te.hybrid</a></li>
<li class="toctree-l2"><a class="reference internal" href="driver.html">tvm.driver</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/index.html">tvm.relay</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/frontend.html">tvm.relay.frontend</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/nn.html">tvm.relay.nn</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/vision.html">tvm.relay.vision</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/image.html">tvm.relay.image</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/transform.html">tvm.relay.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/analysis.html">tvm.relay.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/backend.html">tvm.relay.backend</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/dataflow_pattern.html">tvm.relay.dataflow_pattern</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/testing.html">tvm.relay.testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="autotvm.html">tvm.autotvm</a></li>
<li class="toctree-l2"><a class="reference internal" href="auto_scheduler.html">tvm.auto_scheduler</a></li>
<li class="toctree-l2"><a class="reference internal" href="rpc.html">tvm.rpc</a></li>
<li class="toctree-l2"><a class="reference internal" href="micro.html">tvm.micro</a></li>
<li class="toctree-l2"><a class="reference internal" href="contrib.html">tvm.contrib</a></li>
<li class="toctree-l2"><a class="reference internal" href="graph_executor.html">tvm.contrib.graph_executor</a></li>
<li class="toctree-l2"><a class="reference internal" href="topi.html">tvm.topi</a></li>
<li class="toctree-l2"><a class="reference internal" href="vta/index.html">vta</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../links.html">Other APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../publications.html">Publications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../genindex.html">索引</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
      
      <nav class="wy-nav-top" aria-label="top navigation" data-toggle="wy-nav-top">
        
            <div class="togglemenu">

            </div>
            <div class="nav-content">
              <!-- tvm -->
              Table of content
            </div>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        

          




















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../index.html">Docs</a> <span class="br-arrow">></span></li>
        
          <li><a href="index.html">Python API</a> <span class="br-arrow">></span></li>
        
      <li>tvm.tir</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../../../_sources/reference/api/python/tir.rst.txt" rel="nofollow"> <img src="../../../_static//img/source.svg" alt="viewsource"/></a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-tvm.tir">
<span id="tvm-tir"></span><h1>tvm.tir<a class="headerlink" href="#module-tvm.tir" title="永久链接至标题">¶</a></h1>
<p>Namespace for Tensor-level IR</p>
<p><strong>类：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Buffer</span></code></a>()</p></td>
<td><p>Symbolic data buffer in TVM.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.DataProducer" title="tvm.tir.DataProducer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataProducer</span></code></a>()</p></td>
<td><p></p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Layout" title="tvm.tir.Layout"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Layout</span></code></a>()</p></td>
<td><p>Layout is composed of upper cases, lower cases and numbers, where upper case indicates a primal axis and the corresponding lower case with factor size indicates the subordinate axis.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.BijectiveLayout" title="tvm.tir.BijectiveLayout"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BijectiveLayout</span></code></a>()</p></td>
<td><p>Bijective mapping for two layouts (src-layout and dst-layout).</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Var</span></code></a>(name, dtype, tvm.ir.type.Type], span)</p></td>
<td><p>Symbolic variable.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.SizeVar" title="tvm.tir.SizeVar"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SizeVar</span></code></a>(name, dtype[, span])</p></td>
<td><p>Symbolic variable to represent a tensor index size</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Reduce" title="tvm.tir.Reduce"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Reduce</span></code></a>(combiner, src, rdom, condition, …)</p></td>
<td><p>Reduce node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.FloatImm" title="tvm.tir.FloatImm"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FloatImm</span></code></a>(dtype, value[, span])</p></td>
<td><p>Float constant.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.IntImm" title="tvm.tir.IntImm"><code class="xref py py-obj docutils literal notranslate"><span class="pre">IntImm</span></code></a>(dtype, value[, span])</p></td>
<td><p>Int constant.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.StringImm" title="tvm.tir.StringImm"><code class="xref py py-obj docutils literal notranslate"><span class="pre">StringImm</span></code></a>(value[, span])</p></td>
<td><p>String constant.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Cast" title="tvm.tir.Cast"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Cast</span></code></a>(dtype, value[, span])</p></td>
<td><p>Cast expression.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Add" title="tvm.tir.Add"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Add</span></code></a>(a, b[, span])</p></td>
<td><p>Add node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Sub" title="tvm.tir.Sub"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Sub</span></code></a>(a, b[, span])</p></td>
<td><p>Sub node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Mul" title="tvm.tir.Mul"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Mul</span></code></a>(a, b[, span])</p></td>
<td><p>Mul node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Div" title="tvm.tir.Div"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Div</span></code></a>(a, b[, span])</p></td>
<td><p>Div node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Mod" title="tvm.tir.Mod"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Mod</span></code></a>(a, b[, span])</p></td>
<td><p>Mod node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.FloorDiv" title="tvm.tir.FloorDiv"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FloorDiv</span></code></a>(a, b[, span])</p></td>
<td><p>FloorDiv node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.FloorMod" title="tvm.tir.FloorMod"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FloorMod</span></code></a>(a, b[, span])</p></td>
<td><p>FloorMod node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Min" title="tvm.tir.Min"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Min</span></code></a>(a, b[, span])</p></td>
<td><p>Min node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Max" title="tvm.tir.Max"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Max</span></code></a>(a, b[, span])</p></td>
<td><p>Max node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.EQ" title="tvm.tir.EQ"><code class="xref py py-obj docutils literal notranslate"><span class="pre">EQ</span></code></a>(a, b[, span])</p></td>
<td><p>EQ node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.NE" title="tvm.tir.NE"><code class="xref py py-obj docutils literal notranslate"><span class="pre">NE</span></code></a>(a, b[, span])</p></td>
<td><p>NE node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.LT" title="tvm.tir.LT"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LT</span></code></a>(a, b[, span])</p></td>
<td><p>LT node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.LE" title="tvm.tir.LE"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LE</span></code></a>(a, b[, span])</p></td>
<td><p>LE node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.GT" title="tvm.tir.GT"><code class="xref py py-obj docutils literal notranslate"><span class="pre">GT</span></code></a>(a, b[, span])</p></td>
<td><p>GT node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.GE" title="tvm.tir.GE"><code class="xref py py-obj docutils literal notranslate"><span class="pre">GE</span></code></a>(a, b[, span])</p></td>
<td><p>GE node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.And" title="tvm.tir.And"><code class="xref py py-obj docutils literal notranslate"><span class="pre">And</span></code></a>(a, b[, span])</p></td>
<td><p>And node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Or" title="tvm.tir.Or"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Or</span></code></a>(a, b[, span])</p></td>
<td><p>Or node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Not" title="tvm.tir.Not"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Not</span></code></a>(a[, span])</p></td>
<td><p>Not node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Select" title="tvm.tir.Select"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Select</span></code></a>(condition, true_value, false_value[, …])</p></td>
<td><p>Select node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.BufferLoad" title="tvm.tir.BufferLoad"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BufferLoad</span></code></a>(buffer, indices[, span])</p></td>
<td><p>Buffer load node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.ProducerLoad" title="tvm.tir.ProducerLoad"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ProducerLoad</span></code></a>(producer, indices[, span])</p></td>
<td><p>Producer load node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Load" title="tvm.tir.Load"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Load</span></code></a>(dtype, buffer_var, index[, predicate, span])</p></td>
<td><p>Load node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Ramp" title="tvm.tir.Ramp"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Ramp</span></code></a>(base, stride, lanes[, span])</p></td>
<td><p>Ramp node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Broadcast" title="tvm.tir.Broadcast"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Broadcast</span></code></a>(value, lanes[, span])</p></td>
<td><p>Broadcast node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Shuffle" title="tvm.tir.Shuffle"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Shuffle</span></code></a>(vectors, indices[, span])</p></td>
<td><p>Shuffle node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Call" title="tvm.tir.Call"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Call</span></code></a>(dtype, op, args[, span])</p></td>
<td><p>Call node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.CallEffectKind" title="tvm.tir.CallEffectKind"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CallEffectKind</span></code></a>()</p></td>
<td><p>Possible kinds of Call effects.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Let" title="tvm.tir.Let"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Let</span></code></a>(var, value, body[, span])</p></td>
<td><p>Let node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.IterVar" title="tvm.tir.IterVar"><code class="xref py py-obj docutils literal notranslate"><span class="pre">IterVar</span></code></a>(dom, var, iter_type[, thread_tag, span])</p></td>
<td><p>Represent iteration variable.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Any" title="tvm.tir.Any"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Any</span></code></a>([span])</p></td>
<td><p>Any node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Stmt</span></code></a>()</p></td>
<td><p>Base class of all the statements.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.LetStmt" title="tvm.tir.LetStmt"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LetStmt</span></code></a>(var, value, body[, span])</p></td>
<td><p>LetStmt node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.AssertStmt" title="tvm.tir.AssertStmt"><code class="xref py py-obj docutils literal notranslate"><span class="pre">AssertStmt</span></code></a>(condition, message, body[, span])</p></td>
<td><p>AssertStmt 节点。</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.ForKind" title="tvm.tir.ForKind"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ForKind</span></code></a>(value)</p></td>
<td><p>The kind of the for loop.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.For" title="tvm.tir.For"><code class="xref py py-obj docutils literal notranslate"><span class="pre">For</span></code></a>(loop_var, min_val, extent, kind, body[, …])</p></td>
<td><p>For node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.While" title="tvm.tir.While"><code class="xref py py-obj docutils literal notranslate"><span class="pre">While</span></code></a>(condition, body[, span])</p></td>
<td><p>While node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.BufferStore" title="tvm.tir.BufferStore"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BufferStore</span></code></a>(buffer, value, indices[, span])</p></td>
<td><p>Buffer store node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.BufferRealize" title="tvm.tir.BufferRealize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BufferRealize</span></code></a>(buffer, bounds, condition, body)</p></td>
<td><p>Buffer realize node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Store" title="tvm.tir.Store"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Store</span></code></a>(buffer_var, value, index[, predicate, …])</p></td>
<td><p>Store node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.ProducerStore" title="tvm.tir.ProducerStore"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ProducerStore</span></code></a>(producer, value, indices[, span])</p></td>
<td><p>ProducerStore node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Allocate" title="tvm.tir.Allocate"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Allocate</span></code></a>(buffer_var, dtype, extents, …[, …])</p></td>
<td><p>Allocate node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.AttrStmt" title="tvm.tir.AttrStmt"><code class="xref py py-obj docutils literal notranslate"><span class="pre">AttrStmt</span></code></a>(node, attr_key, value, body[, span])</p></td>
<td><p>AttrStmt node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.ProducerRealize" title="tvm.tir.ProducerRealize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ProducerRealize</span></code></a>(producer, bounds, condition, …)</p></td>
<td><p>ProducerRealize node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.SeqStmt" title="tvm.tir.SeqStmt"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SeqStmt</span></code></a>(seq[, span])</p></td>
<td><p>Sequence of statements.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.IfThenElse" title="tvm.tir.IfThenElse"><code class="xref py py-obj docutils literal notranslate"><span class="pre">IfThenElse</span></code></a>(condition, then_case, else_case)</p></td>
<td><p>IfThenElse node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Evaluate" title="tvm.tir.Evaluate"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Evaluate</span></code></a>(value[, span])</p></td>
<td><p>Evaluate node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Prefetch" title="tvm.tir.Prefetch"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Prefetch</span></code></a>(buffer, bounds[, span])</p></td>
<td><p>Prefetch node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.BufferRegion"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BufferRegion</span></code></a>(buffer, region)</p></td>
<td><p>BufferRegion node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.MatchBufferRegion" title="tvm.tir.MatchBufferRegion"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MatchBufferRegion</span></code></a>(buffer, source)</p></td>
<td><p>MatchBufferRegion node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.Block"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Block</span></code></a>(iter_vars, reads, writes, name_hint, …)</p></td>
<td><p>Block node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.BlockRealize" title="tvm.tir.BlockRealize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BlockRealize</span></code></a>(iter_values, predicate, bool], …)</p></td>
<td><p>BlockRealize node.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PrimFunc</span></code></a>(params, body[, ret_type, …])</p></td>
<td><p>A function declaration expression.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.StmtSRef"><code class="xref py py-obj docutils literal notranslate"><span class="pre">StmtSRef</span></code></a>()</p></td>
<td><p>An object that refers to schedulable elements in the TensorIR, aka “sref”.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.BlockScope" title="tvm.tir.BlockScope"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BlockScope</span></code></a>()</p></td>
<td><p>An object corresponds to each block sref in the sref tree, which tracks the producer-consumer dependency between blocks.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.ScheduleState" title="tvm.tir.ScheduleState"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ScheduleState</span></code></a>(mod, tvm.ir.module.IRModule], …)</p></td>
<td><p>The state of scheduling, which exposes a <cite>Replace</cite> method as the primary resort for all the scheduling primitives to manipulate the TensorIR.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule" title="tvm.tir.Schedule"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Schedule</span></code></a>(mod, tvm.ir.module.IRModule], *, …)</p></td>
<td><p>The user-facing schedule class</p></td>
</tr>
</tbody>
</table>
<p><strong>函数：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.decl_buffer" title="tvm.tir.decl_buffer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">decl_buffer</span></code></a>(shape[, dtype, name, data, …])</p></td>
<td><p>Declare a new symbolic buffer.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.bijective_layout" title="tvm.tir.bijective_layout"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bijective_layout</span></code></a>(src_layout, dst_layout)</p></td>
<td><p>Create a bijective layout mapping.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.layout" title="tvm.tir.layout"><code class="xref py py-obj docutils literal notranslate"><span class="pre">layout</span></code></a>(layout_str)</p></td>
<td><p>Create a layout node from a string.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.stmt_seq" title="tvm.tir.stmt_seq"><code class="xref py py-obj docutils literal notranslate"><span class="pre">stmt_seq</span></code></a>(*args)</p></td>
<td><p>Make sequence of statements</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.stmt_list" title="tvm.tir.stmt_list"><code class="xref py py-obj docutils literal notranslate"><span class="pre">stmt_list</span></code></a>(stmt)</p></td>
<td><p>Make list of stmt from blocks.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.call_packed" title="tvm.tir.call_packed"><code class="xref py py-obj docutils literal notranslate"><span class="pre">call_packed</span></code></a>(*args[, span])</p></td>
<td><p>Build expression by call an external packed function.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.call_intrin" title="tvm.tir.call_intrin"><code class="xref py py-obj docutils literal notranslate"><span class="pre">call_intrin</span></code></a>(dtype, func_name, *args[, span])</p></td>
<td><p>Build expression by calling an intrinsic function.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.call_pure_extern" title="tvm.tir.call_pure_extern"><code class="xref py py-obj docutils literal notranslate"><span class="pre">call_pure_extern</span></code></a>(dtype, func_name, *args[, span])</p></td>
<td><p>Build expression by calling a pure extern function.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.call_extern" title="tvm.tir.call_extern"><code class="xref py py-obj docutils literal notranslate"><span class="pre">call_extern</span></code></a>(dtype, func_name, *args[, span])</p></td>
<td><p>Build expression by calling a extern function.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.call_llvm_intrin" title="tvm.tir.call_llvm_intrin"><code class="xref py py-obj docutils literal notranslate"><span class="pre">call_llvm_intrin</span></code></a>(dtype, name, *args[, span])</p></td>
<td><p>Build expression by calling a llvm intrinsic function</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.call_llvm_pure_intrin" title="tvm.tir.call_llvm_pure_intrin"><code class="xref py py-obj docutils literal notranslate"><span class="pre">call_llvm_pure_intrin</span></code></a>(dtype, name, *args[, span])</p></td>
<td><p>Build expression by calling a pure llvm intrinsic function</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.ret" title="tvm.tir.ret"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ret</span></code></a>(val)</p></td>
<td><p>Create a tir return expression</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.all" title="tvm.tir.all"><code class="xref py py-obj docutils literal notranslate"><span class="pre">all</span></code></a>(*args[, span])</p></td>
<td><p>Create a new expression of the intersection of all conditions in the</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.any" title="tvm.tir.any"><code class="xref py py-obj docutils literal notranslate"><span class="pre">any</span></code></a>(*args[, span])</p></td>
<td><p>Create a new experssion of the union of all conditions in the arguments</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.min_value" title="tvm.tir.min_value"><code class="xref py py-obj docutils literal notranslate"><span class="pre">min_value</span></code></a>(dtype[, span])</p></td>
<td><p>minimum value of dtype</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.max_value" title="tvm.tir.max_value"><code class="xref py py-obj docutils literal notranslate"><span class="pre">max_value</span></code></a>(dtype[, span])</p></td>
<td><p>maximum value of dtype</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.trace" title="tvm.tir.trace"><code class="xref py py-obj docutils literal notranslate"><span class="pre">trace</span></code></a>(args[, trace_action])</p></td>
<td><p>Trace tensor data at the runtime.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.exp" title="tvm.tir.exp"><code class="xref py py-obj docutils literal notranslate"><span class="pre">exp</span></code></a>(x)</p></td>
<td><p>Take exponential of input x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.exp2" title="tvm.tir.exp2"><code class="xref py py-obj docutils literal notranslate"><span class="pre">exp2</span></code></a>(x)</p></td>
<td><p>Calculate 2**x</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.exp10" title="tvm.tir.exp10"><code class="xref py py-obj docutils literal notranslate"><span class="pre">exp10</span></code></a>(x)</p></td>
<td><p>Calculate 10**x</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.log" title="tvm.tir.log"><code class="xref py py-obj docutils literal notranslate"><span class="pre">log</span></code></a>(x)</p></td>
<td><p>Take log of input x.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.log2" title="tvm.tir.log2"><code class="xref py py-obj docutils literal notranslate"><span class="pre">log2</span></code></a>(x)</p></td>
<td><p>Take log2 of input x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.log10" title="tvm.tir.log10"><code class="xref py py-obj docutils literal notranslate"><span class="pre">log10</span></code></a>(x)</p></td>
<td><p>Take log10 of input x.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.log1p" title="tvm.tir.log1p"><code class="xref py py-obj docutils literal notranslate"><span class="pre">log1p</span></code></a>(x)</p></td>
<td><p>Take log(x + 1) with respect to input x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.ldexp" title="tvm.tir.ldexp"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ldexp</span></code></a>(x1, x2)</p></td>
<td><p>Returns x1 * (2 ** x2).</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.clz" title="tvm.tir.clz"><code class="xref py py-obj docutils literal notranslate"><span class="pre">clz</span></code></a>(x)</p></td>
<td><p>Count leading zero bits of an integer x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.sin" title="tvm.tir.sin"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sin</span></code></a>(x)</p></td>
<td><p>Take sin of input x.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.sinh" title="tvm.tir.sinh"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sinh</span></code></a>(x)</p></td>
<td><p>Take sinh of input x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.asin" title="tvm.tir.asin"><code class="xref py py-obj docutils literal notranslate"><span class="pre">asin</span></code></a>(x)</p></td>
<td><p>Take asin of input x.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.asinh" title="tvm.tir.asinh"><code class="xref py py-obj docutils literal notranslate"><span class="pre">asinh</span></code></a>(x)</p></td>
<td><p>Take asinh of input x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.cos" title="tvm.tir.cos"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cos</span></code></a>(x)</p></td>
<td><p>Take cos of input x.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.cosh" title="tvm.tir.cosh"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cosh</span></code></a>(x)</p></td>
<td><p>Take cosh of input x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.acos" title="tvm.tir.acos"><code class="xref py py-obj docutils literal notranslate"><span class="pre">acos</span></code></a>(x)</p></td>
<td><p>Take acos of input x.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.acosh" title="tvm.tir.acosh"><code class="xref py py-obj docutils literal notranslate"><span class="pre">acosh</span></code></a>(x)</p></td>
<td><p>Take acos of input x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.tan" title="tvm.tir.tan"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tan</span></code></a>(x)</p></td>
<td><p>Take tan of input x.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.tanh" title="tvm.tir.tanh"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tanh</span></code></a>(x)</p></td>
<td><p>Take hyperbolic tanh of input x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.atan" title="tvm.tir.atan"><code class="xref py py-obj docutils literal notranslate"><span class="pre">atan</span></code></a>(x)</p></td>
<td><p>Take atan of input x.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.atan2" title="tvm.tir.atan2"><code class="xref py py-obj docutils literal notranslate"><span class="pre">atan2</span></code></a>(x1, x2)</p></td>
<td><p>Take arctan2(x1, x2).</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.atanh" title="tvm.tir.atanh"><code class="xref py py-obj docutils literal notranslate"><span class="pre">atanh</span></code></a>(x)</p></td>
<td><p>Take atanh of input x.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.erf" title="tvm.tir.erf"><code class="xref py py-obj docutils literal notranslate"><span class="pre">erf</span></code></a>(x)</p></td>
<td><p>Take gauss error function of the input x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.sigmoid" title="tvm.tir.sigmoid"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sigmoid</span></code></a>(x)</p></td>
<td><p>Quick function to get sigmoid</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.sqrt" title="tvm.tir.sqrt"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sqrt</span></code></a>(x)</p></td>
<td><p>Take square root of input x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.rsqrt" title="tvm.tir.rsqrt"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rsqrt</span></code></a>(x)</p></td>
<td><p>Take reciprocal of square root of input x.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.floor" title="tvm.tir.floor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">floor</span></code></a>(x[, span])</p></td>
<td><p>Take floor of float input x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.ceil" title="tvm.tir.ceil"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ceil</span></code></a>(x[, span])</p></td>
<td><p>Take ceil of float input x.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.hypot" title="tvm.tir.hypot"><code class="xref py py-obj docutils literal notranslate"><span class="pre">hypot</span></code></a>(x1, x2)</p></td>
<td><p>Equivalent to sqrt(x1**2 + x2**2), element-wise.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.trunc" title="tvm.tir.trunc"><code class="xref py py-obj docutils literal notranslate"><span class="pre">trunc</span></code></a>(x[, span])</p></td>
<td><p>Get truncated value of the input.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.abs" title="tvm.tir.abs"><code class="xref py py-obj docutils literal notranslate"><span class="pre">abs</span></code></a>(x[, span])</p></td>
<td><p>Get absolute value of the input element-wise.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.round" title="tvm.tir.round"><code class="xref py py-obj docutils literal notranslate"><span class="pre">round</span></code></a>(x[, span])</p></td>
<td><p>Round elements of the array to the nearest integer.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.nextafter" title="tvm.tir.nextafter"><code class="xref py py-obj docutils literal notranslate"><span class="pre">nextafter</span></code></a>(x1, x2)</p></td>
<td><p>Return the next floating-point value after x1 towards x2.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.nearbyint" title="tvm.tir.nearbyint"><code class="xref py py-obj docutils literal notranslate"><span class="pre">nearbyint</span></code></a>(x[, span])</p></td>
<td><p>Round elements of the array to the nearest integer.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.power" title="tvm.tir.power"><code class="xref py py-obj docutils literal notranslate"><span class="pre">power</span></code></a>(x, y[, span])</p></td>
<td><p>x power y</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.popcount" title="tvm.tir.popcount"><code class="xref py py-obj docutils literal notranslate"><span class="pre">popcount</span></code></a>(x)</p></td>
<td><p>Count the number of set bits in input x.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.fmod" title="tvm.tir.fmod"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fmod</span></code></a>(x, y)</p></td>
<td><p>Return the remainder of x divided by y with the same sign as x.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.if_then_else" title="tvm.tir.if_then_else"><code class="xref py py-obj docutils literal notranslate"><span class="pre">if_then_else</span></code></a>(cond, t, f[, span])</p></td>
<td><p>Conditional selection expression.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.isnan" title="tvm.tir.isnan"><code class="xref py py-obj docutils literal notranslate"><span class="pre">isnan</span></code></a>(x[, span])</p></td>
<td><p>Check if input value is Nan.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.isfinite" title="tvm.tir.isfinite"><code class="xref py py-obj docutils literal notranslate"><span class="pre">isfinite</span></code></a>(x[, span])</p></td>
<td><p>Check if input value is finite.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.isinf" title="tvm.tir.isinf"><code class="xref py py-obj docutils literal notranslate"><span class="pre">isinf</span></code></a>(x[, span])</p></td>
<td><p>Check if input value is infinite.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.copysign" title="tvm.tir.copysign"><code class="xref py py-obj docutils literal notranslate"><span class="pre">copysign</span></code></a>(x1, x2)</p></td>
<td><p>Change the sign of x1 to that of x2, element-wise.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.div" title="tvm.tir.div"><code class="xref py py-obj docutils literal notranslate"><span class="pre">div</span></code></a>(a, b[, span])</p></td>
<td><p>Compute a / b as in C/C++ semantics.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.indexdiv" title="tvm.tir.indexdiv"><code class="xref py py-obj docutils literal notranslate"><span class="pre">indexdiv</span></code></a>(a, b[, span])</p></td>
<td><p>Compute floor(a / b) where a and b are non-negative.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.indexmod" title="tvm.tir.indexmod"><code class="xref py py-obj docutils literal notranslate"><span class="pre">indexmod</span></code></a>(a, b[, span])</p></td>
<td><p>Compute the remainder of indexdiv.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.truncdiv" title="tvm.tir.truncdiv"><code class="xref py py-obj docutils literal notranslate"><span class="pre">truncdiv</span></code></a>(a, b[, span])</p></td>
<td><p>Compute the truncdiv of two expressions.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.truncmod" title="tvm.tir.truncmod"><code class="xref py py-obj docutils literal notranslate"><span class="pre">truncmod</span></code></a>(a, b[, span])</p></td>
<td><p>Compute the truncmod of two expressions.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.floordiv" title="tvm.tir.floordiv"><code class="xref py py-obj docutils literal notranslate"><span class="pre">floordiv</span></code></a>(a, b[, span])</p></td>
<td><p>Compute the floordiv of two expressions.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.floormod" title="tvm.tir.floormod"><code class="xref py py-obj docutils literal notranslate"><span class="pre">floormod</span></code></a>(a, b[, span])</p></td>
<td><p>Compute the floormod of two expressions.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.comm_reducer" title="tvm.tir.comm_reducer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">comm_reducer</span></code></a>(fcombine, fidentity[, name])</p></td>
<td><p>Create a commutative reducer for reduction.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.min" title="tvm.tir.min"><code class="xref py py-obj docutils literal notranslate"><span class="pre">min</span></code></a>(expr, axis[, where, init])</p></td>
<td><p>Create a min expression over axis.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.max" title="tvm.tir.max"><code class="xref py py-obj docutils literal notranslate"><span class="pre">max</span></code></a>(expr, axis[, where, init])</p></td>
<td><p>Create a max expression over axis.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.sum" title="tvm.tir.sum"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sum</span></code></a>(expr, axis[, where, init])</p></td>
<td><p>Create a sum expression over axis.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.q_multiply_shift" title="tvm.tir.q_multiply_shift"><code class="xref py py-obj docutils literal notranslate"><span class="pre">q_multiply_shift</span></code></a>(x, y, q, s)</p></td>
<td><p>Execute a multiplication between two Q-numbers x and y followed by a right shift s.</p></td>
</tr>
</tbody>
</table>
<p><strong>Exceptions:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.ScheduleError" title="tvm.tir.ScheduleError"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ScheduleError</span></code></a></p></td>
<td><p>Error that happens during TensorIR scheduling.</p></td>
</tr>
</tbody>
</table>
<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Buffer">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Buffer</span></span><a class="headerlink" href="#tvm.tir.Buffer" title="永久链接至目标">¶</a></dt>
<dd><p>Symbolic data buffer in TVM.</p>
<p>Buffer provide a way to represent data layout
specialization of data structure in TVM.</p>
<p>Do not construct directly, use <a class="reference internal" href="#tvm.tir.decl_buffer" title="tvm.tir.decl_buffer"><code class="xref py py-func docutils literal notranslate"><span class="pre">decl_buffer()</span></code></a> instead.
See the documentation of <a class="reference internal" href="#tvm.tir.decl_buffer" title="tvm.tir.decl_buffer"><code class="xref py py-func docutils literal notranslate"><span class="pre">decl_buffer()</span></code></a> for more details.</p>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<dl class="simple">
<dt><a class="reference internal" href="#tvm.tir.decl_buffer" title="tvm.tir.decl_buffer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">decl_buffer</span></code></a></dt><dd><p>Declare a buffer</p>
</dd>
</dl>
</div>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Buffer.access_ptr" title="tvm.tir.Buffer.access_ptr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">access_ptr</span></code></a>(access_mask[, ptr_type, …])</p></td>
<td><p>Get an access pointer to the head of buffer.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Buffer.vload" title="tvm.tir.Buffer.vload"><code class="xref py py-obj docutils literal notranslate"><span class="pre">vload</span></code></a>(begin[, dtype])</p></td>
<td><p>Generate an Expr that loads dtype from begin index.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Buffer.vstore" title="tvm.tir.Buffer.vstore"><code class="xref py py-obj docutils literal notranslate"><span class="pre">vstore</span></code></a>(begin, value)</p></td>
<td><p>Generate a Stmt that store value into begin index.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Buffer.scope" title="tvm.tir.Buffer.scope"><code class="xref py py-obj docutils literal notranslate"><span class="pre">scope</span></code></a>()</p></td>
<td><p>Return the storage scope associated with this buffer.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Buffer.access_ptr">
<span class="sig-name descname"><span class="pre">access_ptr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">access_mask</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ptr_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'handle'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">content_lanes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">offset</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Buffer.access_ptr" title="永久链接至目标">¶</a></dt>
<dd><p>Get an access pointer to the head of buffer.</p>
<p>This is the recommended method to get buffer data
ptress when interacting with external functions.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>access_mask</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The access pattern MASK. Indicate whether the
access will read or write to the data content.</p></li>
<li><p><strong>ptr_type</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The data type of the result pointer. Do not specify
unless we want to cast pointer to specific type.</p></li>
<li><p><strong>content_lanes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The number of lanes for the data type. This value
is greater than one for vector types.</p></li>
<li><p><strong>offset</strong> (<em>Expr</em><em>, </em><em>optional</em>) – The offset of pointer. We can use it to offset by
the number of elements from the address of ptr.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">实际案例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Get access ptr for read</span>
<span class="nb">buffer</span><span class="o">.</span><span class="n">access_ptr</span><span class="p">(</span><span class="s2">&quot;r&quot;</span><span class="p">)</span>
<span class="c1"># Get access ptr for read/write with bitmask</span>
<span class="nb">buffer</span><span class="o">.</span><span class="n">access_ptr</span><span class="p">(</span><span class="n">Buffer</span><span class="o">.</span><span class="n">READ</span> <span class="o">|</span> <span class="n">Buffer</span><span class="o">.</span><span class="n">WRITE</span><span class="p">)</span>
<span class="c1"># Get access ptr for read/write with str flag</span>
<span class="nb">buffer</span><span class="o">.</span><span class="n">access_ptr</span><span class="p">(</span><span class="s2">&quot;rw&quot;</span><span class="p">)</span>
<span class="c1"># Get access ptr for read with offset</span>
<span class="nb">buffer</span><span class="o">.</span><span class="n">access_ptr</span><span class="p">(</span><span class="s2">&quot;r&quot;</span><span class="p">,</span> <span class="n">offset</span> <span class="o">=</span> <span class="mi">100</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Buffer.vload">
<span class="sig-name descname"><span class="pre">vload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">begin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Buffer.vload" title="永久链接至目标">¶</a></dt>
<dd><p>Generate an Expr that loads dtype from begin index.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>begin</strong> (<em>Array of Expr</em>) – The beginning index in unit of Buffer.dtype</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type to be loaded,
can be vector type which have lanes that is multiple of Buffer.dtype</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>load</strong> – The corresponding load expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Buffer.vstore">
<span class="sig-name descname"><span class="pre">vstore</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">begin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Buffer.vstore" title="永久链接至目标">¶</a></dt>
<dd><p>Generate a Stmt that store value into begin index.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>begin</strong> (<em>Array of Expr</em>) – The beginning index in unit of Buffer.dtype</p></li>
<li><p><strong>value</strong> (<em>Expr</em>) – The value to be stored.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>store</strong> – The corresponding store stmt.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt">Stmt</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Buffer.scope">
<span class="sig-name descname"><span class="pre">scope</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Buffer.scope" title="永久链接至目标">¶</a></dt>
<dd><p>Return the storage scope associated with this buffer.
:returns: <strong>scope</strong> – The storage scope associated with this buffer.
:rtype: str</p>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.decl_buffer">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">decl_buffer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'buffer'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">strides</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">elem_offset</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">scope</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_alignment</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">offset_factor</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">buffer_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.decl_buffer" title="永久链接至目标">¶</a></dt>
<dd><p>Declare a new symbolic buffer.</p>
<p>Normally buffer is created automatically during lower and build.
This is only needed if user want to specify their own buffer layout.</p>
<p>See the note below for detailed discussion on usage of buffer.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>shape</strong> (<em>tuple of Expr</em>) – The shape of the buffer.</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The data type of the buffer.</p></li>
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The name of the buffer.</p></li>
<li><p><strong>data</strong> (<a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a><em>, </em><em>optional</em>) – The data pointer in the buffer.</p></li>
<li><p><strong>strides</strong> (<em>array of Expr</em>) – The stride of the buffer.</p></li>
<li><p><strong>elem_offset</strong> (<em>Expr</em><em>, </em><em>optional</em>) – The beginning offset of the array to data.
In terms of number of elements of dtype.</p></li>
<li><p><strong>scope</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The storage scope of the buffer, if not global.
If scope equals empty string, it means it is global memory.</p></li>
<li><p><strong>data_alignment</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The alignment of data pointer in bytes.
If -1 is passed, the alignment will be set to TVM’s internal default.</p></li>
<li><p><strong>offset_factor</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The factor of elem_offset field, when set,
elem_offset is required to be multiple of offset_factor.
If 0 is pssed, the alignment will be set to 1.
if non-zero is passed, we will created a Var for elem_offset if elem_offset is not None.</p></li>
<li><p><strong>buffer_type</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em><em>, </em><em>{&quot;&quot;</em><em>, </em><em>&quot;auto_broadcast&quot;}</em>) – auto_broadcast buffer allows one to implement broadcast computation
without considering whether dimension size equals to one.
TVM maps buffer[i][j][k] -&gt; buffer[i][0][k] if dimension j’s shape equals 1.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of the decl_buffer creation in the source.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>buffer</strong> – The created buffer</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer">tvm.tir.Buffer</a></p>
</dd>
</dl>
<p class="rubric">示例</p>
<p>Here’s an example of how broadcast buffer can be used to define a symbolic broadcast operation,</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">m0</span><span class="p">,</span> <span class="n">m1</span><span class="p">,</span> <span class="n">m2</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;m0&quot;</span><span class="p">),</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;m1&quot;</span><span class="p">),</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;m2&quot;</span><span class="p">)</span>
<span class="n">n0</span><span class="p">,</span> <span class="n">n1</span><span class="p">,</span> <span class="n">n2</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;n0&quot;</span><span class="p">),</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;n1&quot;</span><span class="p">),</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;n2&quot;</span><span class="p">)</span>
<span class="n">o0</span><span class="p">,</span> <span class="n">o1</span><span class="p">,</span> <span class="n">o2</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;o0&quot;</span><span class="p">),</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;o1&quot;</span><span class="p">),</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;o2&quot;</span><span class="p">)</span>
<span class="n">A</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">placeholder</span><span class="p">((</span><span class="n">m0</span><span class="p">,</span> <span class="n">m1</span><span class="p">,</span> <span class="n">m2</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;A&#39;</span><span class="p">)</span>
<span class="n">B</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">placeholder</span><span class="p">((</span><span class="n">n0</span><span class="p">,</span> <span class="n">n1</span><span class="p">,</span> <span class="n">n2</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;B&#39;</span><span class="p">)</span>
<span class="n">C</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">compute</span><span class="p">((</span><span class="n">o0</span><span class="p">,</span> <span class="n">o1</span><span class="p">,</span> <span class="n">o2</span><span class="p">),</span> <span class="k">lambda</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span><span class="p">:</span> <span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span><span class="p">]</span> <span class="o">+</span> <span class="n">B</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span><span class="p">],</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;C&#39;</span><span class="p">)</span>
<span class="n">Ab</span> <span class="o">=</span> <span class="n">tvm</span><span class="o">.</span><span class="n">tir</span><span class="o">.</span><span class="n">decl_buffer</span><span class="p">(</span><span class="n">A</span><span class="o">.</span><span class="n">shape</span><span class="p">,</span> <span class="n">A</span><span class="o">.</span><span class="n">dtype</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;Ab&quot;</span><span class="p">,</span> <span class="n">buffer_type</span><span class="o">=</span><span class="s2">&quot;auto_broadcast&quot;</span><span class="p">)</span>
<span class="n">Bb</span> <span class="o">=</span> <span class="n">tvm</span><span class="o">.</span><span class="n">tir</span><span class="o">.</span><span class="n">decl_buffer</span><span class="p">(</span><span class="n">B</span><span class="o">.</span><span class="n">shape</span><span class="p">,</span> <span class="n">B</span><span class="o">.</span><span class="n">dtype</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;Bb&quot;</span><span class="p">,</span> <span class="n">buffer_type</span><span class="o">=</span><span class="s2">&quot;auto_broadcast&quot;</span><span class="p">)</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">create_schedule</span><span class="p">(</span><span class="n">C</span><span class="o">.</span><span class="n">op</span><span class="p">)</span>
<span class="n">fadd</span> <span class="o">=</span> <span class="n">tvm</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="p">[</span><span class="n">A</span><span class="p">,</span> <span class="n">B</span><span class="p">,</span> <span class="n">C</span><span class="p">],</span> <span class="n">target</span><span class="o">=</span><span class="s1">&#39;llvm&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;bcast_add&#39;</span><span class="p">,</span> <span class="n">binds</span><span class="o">=</span><span class="p">{</span><span class="n">A</span><span class="p">:</span><span class="n">Ab</span><span class="p">,</span> <span class="n">B</span><span class="p">:</span><span class="n">Bb</span><span class="p">})</span>
<span class="n">dev</span> <span class="o">=</span> <span class="n">tvm</span><span class="o">.</span><span class="n">cpu</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">tvm</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">A</span><span class="o">.</span><span class="n">dtype</span><span class="p">),</span> <span class="n">dev</span><span class="p">)</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">tvm</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">B</span><span class="o">.</span><span class="n">dtype</span><span class="p">),</span> <span class="n">dev</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">tvm</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">dtype</span><span class="o">=</span><span class="n">C</span><span class="o">.</span><span class="n">dtype</span><span class="p">),</span> <span class="n">dev</span><span class="p">)</span>
<span class="n">fadd</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span>
<span class="n">tvm</span><span class="o">.</span><span class="n">testing</span><span class="o">.</span><span class="n">assert_allclose</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">numpy</span><span class="p">(),</span> <span class="n">a</span><span class="o">.</span><span class="n">numpy</span><span class="p">()</span> <span class="o">+</span> <span class="n">b</span><span class="o">.</span><span class="n">numpy</span><span class="p">())</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>Buffer data structure reflects the DLTensor structure in dlpack.
While DLTensor data structure is very general, it is usually helpful
to create function that only handles specific case of data structure
and make compiled function benefit from it.</p>
<p>If user pass strides and elem_offset is passed as None
when constructing the function, then the function will be specialized
for the DLTensor that is compact and aligned.
If user pass a fully generic symbolic array to the strides,
then the resulting function becomes fully generic.</p>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.DataProducer">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">DataProducer</span></span><a class="headerlink" href="#tvm.tir.DataProducer" title="永久链接至目标">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Layout">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Layout</span></span><a class="headerlink" href="#tvm.tir.Layout" title="永久链接至目标">¶</a></dt>
<dd><p>Layout is composed of upper cases, lower cases and numbers,
where upper case indicates a primal axis and
the corresponding lower case with factor size indicates the subordinate axis.
For example, NCHW16c can describe a 5-D tensor of
[batch_size, channel, height, width, channel_block].
Here subordinate axis channel_block=16 is the factor size of the primal axis C (channel).</p>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<dl class="simple">
<dt><a class="reference internal" href="#tvm.tir.layout" title="tvm.tir.layout"><code class="xref py py-obj docutils literal notranslate"><span class="pre">layout</span></code></a></dt><dd><p>Declare a layout</p>
</dd>
</dl>
</div>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Layout.index_of" title="tvm.tir.Layout.index_of"><code class="xref py py-obj docutils literal notranslate"><span class="pre">index_of</span></code></a>(axis)</p></td>
<td><p>Get the index of an axis</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Layout.factor_of" title="tvm.tir.Layout.factor_of"><code class="xref py py-obj docutils literal notranslate"><span class="pre">factor_of</span></code></a>(axis)</p></td>
<td><p>Get the factor size of the subordinate axis.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Layout.index_of">
<span class="sig-name descname"><span class="pre">index_of</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">axis</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Layout.index_of" title="永久链接至目标">¶</a></dt>
<dd><p>Get the index of an axis</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>axis</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The axis name, need to be [a-z,A-Z]</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>index</strong> – The index of the axis, -1 if not found.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Layout.factor_of">
<span class="sig-name descname"><span class="pre">factor_of</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">axis</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Layout.factor_of" title="永久链接至目标">¶</a></dt>
<dd><p>Get the factor size of the subordinate axis.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>axis</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The axis name, need to be [a-z,A-Z]</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>factor</strong> – the size of the subordinate-axis of axis (if axis is a primal-axis),
or the size of axis itself (if axis is a subordinate-axis).
Return -1 if axis is not in the layout.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a></p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.BijectiveLayout">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">BijectiveLayout</span></span><a class="headerlink" href="#tvm.tir.BijectiveLayout" title="永久链接至目标">¶</a></dt>
<dd><p>Bijective mapping for two layouts (src-layout and dst-layout).
It provides shape and index conversion between each other.</p>
<p>Do not construct directly, use <a class="reference internal" href="#tvm.tir.bijective_layout" title="tvm.tir.bijective_layout"><code class="xref any py py-func docutils literal notranslate"><span class="pre">bijective_layout</span></code></a> instead.
See the documentation of <a class="reference internal" href="#tvm.tir.bijective_layout" title="tvm.tir.bijective_layout"><code class="xref any py py-func docutils literal notranslate"><span class="pre">bijective_layout</span></code></a> for more details.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>src_layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><a class="reference internal" href="#tvm.tir.Layout" title="tvm.tir.Layout"><em>Layout</em></a>) – source layout.</p></li>
<li><p><strong>dst_layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><a class="reference internal" href="#tvm.tir.Layout" title="tvm.tir.Layout"><em>Layout</em></a>) – destination layout.</p></li>
</ul>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<dl class="simple">
<dt><a class="reference internal" href="#tvm.tir.bijective_layout" title="tvm.tir.bijective_layout"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bijective_layout</span></code></a></dt><dd><p>Declare a layout</p>
</dd>
</dl>
</div>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.BijectiveLayout.forward_index" title="tvm.tir.BijectiveLayout.forward_index"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forward_index</span></code></a>(index)</p></td>
<td><p>Given the indices of the src-layout, infer the dst index.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.BijectiveLayout.backward_index" title="tvm.tir.BijectiveLayout.backward_index"><code class="xref py py-obj docutils literal notranslate"><span class="pre">backward_index</span></code></a>(index)</p></td>
<td><p>Given the indices of the dst-layout, infer the src index.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.BijectiveLayout.forward_shape" title="tvm.tir.BijectiveLayout.forward_shape"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forward_shape</span></code></a>(shape)</p></td>
<td><p>Given the shape of the src-layout, infer the dst shape.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.BijectiveLayout.backward_shape" title="tvm.tir.BijectiveLayout.backward_shape"><code class="xref py py-obj docutils literal notranslate"><span class="pre">backward_shape</span></code></a>(shape)</p></td>
<td><p>Given the shape of the dst-layout, infer the src shape.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.BijectiveLayout.forward_index">
<span class="sig-name descname"><span class="pre">forward_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.BijectiveLayout.forward_index" title="永久链接至目标">¶</a></dt>
<dd><p>Given the indices of the src-layout, infer the dst index.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>index</strong> (<em>Array of Expr</em>) – The indices in src-layout.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dst_index</strong> – The inferred indices in dst-layout.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Array of Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.BijectiveLayout.backward_index">
<span class="sig-name descname"><span class="pre">backward_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.BijectiveLayout.backward_index" title="永久链接至目标">¶</a></dt>
<dd><p>Given the indices of the dst-layout, infer the src index.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>index</strong> (<em>Array of Expr</em>) – The indices in dst-layout.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>src_index</strong> – The inferred indices in src-layout.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Array of Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.BijectiveLayout.forward_shape">
<span class="sig-name descname"><span class="pre">forward_shape</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shape</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.BijectiveLayout.forward_shape" title="永久链接至目标">¶</a></dt>
<dd><p>Given the shape of the src-layout, infer the dst shape.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>shape</strong> (<em>Array of Expr</em>) – The shape in src-layout.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dst_shape</strong> – The inferred shape in dst-layout.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Array of Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.BijectiveLayout.backward_shape">
<span class="sig-name descname"><span class="pre">backward_shape</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shape</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.BijectiveLayout.backward_shape" title="永久链接至目标">¶</a></dt>
<dd><p>Given the shape of the dst-layout, infer the src shape.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>shape</strong> (<em>Array of Expr</em>) – The shape in dst-layout.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>src_shape</strong> – The inferred shape in src-layout.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Array of Expr</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.bijective_layout">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">bijective_layout</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">src_layout</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.Layout" title="tvm.tir.data_layout.Layout"><span class="pre">tvm.tir.data_layout.Layout</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dst_layout</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.Layout" title="tvm.tir.data_layout.Layout"><span class="pre">tvm.tir.data_layout.Layout</span></a><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#tvm.tir.BijectiveLayout" title="tvm.tir.data_layout.BijectiveLayout"><span class="pre">tvm.tir.data_layout.BijectiveLayout</span></a></span></span><a class="headerlink" href="#tvm.tir.bijective_layout" title="永久链接至目标">¶</a></dt>
<dd><p>Create a bijective layout mapping.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>src_layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><a class="reference internal" href="#tvm.tir.Layout" title="tvm.tir.Layout"><em>Layout</em></a>) – source layout.</p></li>
<li><p><strong>dst_layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><a class="reference internal" href="#tvm.tir.Layout" title="tvm.tir.Layout"><em>Layout</em></a>) – destination layout.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>bijective_layout</strong> – The created bijective layout</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.tir.BijectiveLayout" title="tvm.tir.BijectiveLayout">BijectiveLayout</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.layout">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">layout</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">layout_str</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#tvm.tir.Layout" title="tvm.tir.data_layout.Layout"><span class="pre">tvm.tir.data_layout.Layout</span></a></span></span><a class="headerlink" href="#tvm.tir.layout" title="永久链接至目标">¶</a></dt>
<dd><p>Create a layout node from a string.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>layout_str</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – A layout representation is composed of upper cases, lower cases and numbers,
where upper case indicates a primal axis and
the corresponding lower case with factor size indicates the subordinate axis.
For example, NCHW16c can describe a 5-D tensor of
[batch_size, channel, height, width, channel_block].
Here subordinate axis channel_block=16 is the factor size of
the primal axis C (channel).</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>layout</strong> – The created layout</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.tir.Layout" title="tvm.tir.Layout">Layout</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Var">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Var</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="ir.html#tvm.ir.Type" title="tvm.ir.type.Type"><span class="pre">tvm.ir.type.Type</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.base.Span"><span class="pre">tvm.ir.base.Span</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Var" title="永久链接至目标">¶</a></dt>
<dd><p>Symbolic variable.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name</p></li>
<li><p><strong>dtype</strong> (<em>Union</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>tvm.irType</em><em>]</em>) – The data type</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.SizeVar">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">SizeVar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.SizeVar" title="永久链接至目标">¶</a></dt>
<dd><dl class="simple">
<dt>Symbolic variable to represent a tensor index size</dt><dd><p>which is greater or equal to zero.</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The data type</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Reduce">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Reduce</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">combiner</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">src</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rdom</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">condition</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value_index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">init</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Reduce" title="永久链接至目标">¶</a></dt>
<dd><p>Reduce node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>combiner</strong> (<em>CommReducer</em>) – The combiner.</p></li>
<li><p><strong>src</strong> (<em>list of Expr</em>) – The source expression.</p></li>
<li><p><strong>rdom</strong> (<em>list of IterVar</em>) – The iteration domain</p></li>
<li><p><strong>condition</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The reduce condition.</p></li>
<li><p><strong>value_index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The value index.</p></li>
<li><p><strong>init</strong> (<em>list of Expr</em>) – The initial value for output. This can be an int, float or ProducerLoad</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.FloatImm">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">FloatImm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.FloatImm" title="永久链接至目标">¶</a></dt>
<dd><p>Float constant.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type</p></li>
<li><p><strong>value</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a>) – The constant value.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.IntImm">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">IntImm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.IntImm" title="永久链接至目标">¶</a></dt>
<dd><p>Int constant.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type</p></li>
<li><p><strong>value</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The constant value.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.StringImm">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">StringImm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.StringImm" title="永久链接至目标">¶</a></dt>
<dd><p>String constant.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The value of the function.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Cast">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Cast</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Cast" title="永久链接至目标">¶</a></dt>
<dd><p>Cast expression.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type</p></li>
<li><p><strong>value</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The value of the function.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Add">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Add" title="永久链接至目标">¶</a></dt>
<dd><p>Add node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Sub">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Sub</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Sub" title="永久链接至目标">¶</a></dt>
<dd><p>Sub node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Mul">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Mul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Mul" title="永久链接至目标">¶</a></dt>
<dd><p>Mul node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Div">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Div</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Div" title="永久链接至目标">¶</a></dt>
<dd><p>Div node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Mod">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Mod</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Mod" title="永久链接至目标">¶</a></dt>
<dd><p>Mod node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.FloorDiv">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">FloorDiv</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.FloorDiv" title="永久链接至目标">¶</a></dt>
<dd><p>FloorDiv node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.FloorMod">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">FloorMod</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.FloorMod" title="永久链接至目标">¶</a></dt>
<dd><p>FloorMod node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Min">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Min</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Min" title="永久链接至目标">¶</a></dt>
<dd><p>Min node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Max">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Max</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Max" title="永久链接至目标">¶</a></dt>
<dd><p>Max node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.EQ">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">EQ</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.EQ" title="永久链接至目标">¶</a></dt>
<dd><p>EQ node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.NE">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">NE</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.NE" title="永久链接至目标">¶</a></dt>
<dd><p>NE node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.LT">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">LT</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.LT" title="永久链接至目标">¶</a></dt>
<dd><p>LT node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.LE">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">LE</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.LE" title="永久链接至目标">¶</a></dt>
<dd><p>LE node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.GT">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">GT</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.GT" title="永久链接至目标">¶</a></dt>
<dd><p>GT node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.GE">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">GE</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.GE" title="永久链接至目标">¶</a></dt>
<dd><p>GE node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.And">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">And</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.And" title="永久链接至目标">¶</a></dt>
<dd><p>And node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Or">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Or</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Or" title="永久链接至目标">¶</a></dt>
<dd><p>Or node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Not">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Not</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Not" title="永久链接至目标">¶</a></dt>
<dd><p>Not node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The input value</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Select">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Select</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">condition</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">true_value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">false_value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Select" title="永久链接至目标">¶</a></dt>
<dd><p>Select node.</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>Select may compute both true_value and false_value.
Use <a class="reference internal" href="#tvm.tir.if_then_else" title="tvm.tir.if_then_else"><code class="xref py py-class docutils literal notranslate"><span class="pre">tvm.tir.if_then_else</span></code></a> instead if you want to
get a conditional expression that only evaluates
the correct branch.</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>condition</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The condition expression.</p></li>
<li><p><strong>true_value</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The value to take when condition is true.</p></li>
<li><p><strong>false_value</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The value to take when condition is false.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.BufferLoad">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">BufferLoad</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">buffer</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indices</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.BufferLoad" title="永久链接至目标">¶</a></dt>
<dd><p>Buffer load node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>buffer</strong> (<a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a>) – The buffer to be loaded.</p></li>
<li><p><strong>indices</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a><em>]</em>) – The buffer indices.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.ProducerLoad">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">ProducerLoad</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">producer</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indices</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.ProducerLoad" title="永久链接至目标">¶</a></dt>
<dd><p>Producer load node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>producer</strong> (<a class="reference internal" href="#tvm.tir.DataProducer" title="tvm.tir.DataProducer"><em>DataProducer</em></a>) – The buffer to be loaded.</p></li>
<li><p><strong>indices</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a><em>]</em>) – The buffer indices.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Load">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Load</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">buffer_var</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">predicate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Load" title="永久链接至目标">¶</a></dt>
<dd><p>Load node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type.</p></li>
<li><p><strong>buffer_var</strong> (<a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a>) – The buffer variable in the load expression.</p></li>
<li><p><strong>index</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The index in the load.</p></li>
<li><p><strong>predicate</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The load predicate.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Ramp">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Ramp</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">base</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stride</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lanes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Ramp" title="永久链接至目标">¶</a></dt>
<dd><p>Ramp node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>base</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The base expression.</p></li>
<li><p><strong>stride</strong> (<em>ramp stride</em>) – The stride of the ramp.</p></li>
<li><p><strong>lanes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The lanes of the expression.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Broadcast">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Broadcast</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lanes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Broadcast" title="永久链接至目标">¶</a></dt>
<dd><p>Broadcast node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The value of the expression.</p></li>
<li><p><strong>lanes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The lanes of the expression.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Shuffle">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Shuffle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">vectors</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indices</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Shuffle" title="永久链接至目标">¶</a></dt>
<dd><p>Shuffle node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>vectors</strong> (<em>Array of Expr</em>) – The vectors</p></li>
<li><p><strong>indices</strong> (<em>Array of indices</em>) – The indices</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Call">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Call</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">op</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Call" title="永久链接至目标">¶</a></dt>
<dd><p>Call node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The return data type</p></li>
<li><p><strong>op</strong> (<em>Union</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.RelayExpr" title="tvm.ir.RelayExpr"><em>RelayExpr</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – The function to be called, or the name
to the global tvm.Op</p></li>
<li><p><strong>args</strong> (<em>list of Expr</em>) – The input arguments to the call</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.CallEffectKind">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">CallEffectKind</span></span><a class="headerlink" href="#tvm.tir.CallEffectKind" title="永久链接至目标">¶</a></dt>
<dd><p>Possible kinds of Call effects.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Let">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Let</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">var</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Let" title="永久链接至目标">¶</a></dt>
<dd><p>Let node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>var</strong> (<a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a>) – The variable in the binding.</p></li>
<li><p><strong>value</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The value in to be binded.</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The body expression.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.IterVar">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">IterVar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dom</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">iter_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">thread_tag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.IterVar" title="永久链接至目标">¶</a></dt>
<dd><p>Represent iteration variable.</p>
<p>IterVar represents axis iterations in the computation.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dom</strong> (<a class="reference internal" href="ir.html#tvm.ir.Range" title="tvm.ir.Range"><em>Range</em></a>) – The domain of the iteration.</p></li>
<li><p><strong>var</strong> (<em>Union</em><em>[</em><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – The internal variable that is used for iteration.</p></li>
<li><p><strong>iter_type</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The iteration type.</p></li>
<li><p><strong>thread_tag</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The thread type tag.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<dl class="simple">
<dt><code class="xref py py-obj docutils literal notranslate"><span class="pre">te.thread_axis</span></code></dt><dd><p>Create thread axis IterVar.</p>
</dd>
<dt><code class="xref py py-obj docutils literal notranslate"><span class="pre">te.reduce_axis</span></code></dt><dd><p>Create reduce axis IterVar.</p>
</dd>
</dl>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Any">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Any</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Any" title="永久链接至目标">¶</a></dt>
<dd><p>Any node.</p>
<dl class="simple">
<dt>span<span class="classifier">Optional[Span]</span></dt><dd><p>The location of this itervar in the source code.</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Stmt">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Stmt</span></span><a class="headerlink" href="#tvm.tir.Stmt" title="永久链接至目标">¶</a></dt>
<dd><p>Base class of all the statements.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.LetStmt">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">LetStmt</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">var</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.LetStmt" title="永久链接至目标">¶</a></dt>
<dd><p>LetStmt node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>var</strong> (<a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a>) – The variable in the binding.</p></li>
<li><p><strong>value</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The value in to be binded.</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The body statement.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.AssertStmt">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">AssertStmt</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">condition</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">message</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.AssertStmt" title="永久链接至目标">¶</a></dt>
<dd><p>AssertStmt 节点。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>condition</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The assert condition.</p></li>
<li><p><strong>message</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The error message.</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>tvm.tir.Stmt</em></a>) – The body statement.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.ForKind">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">ForKind</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.ForKind" title="永久链接至目标">¶</a></dt>
<dd><p>The kind of the for loop.</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>ForKind can change the control flow semantics
of the loop and need to be considered in all TIR passes.</p>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.For">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">For</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">loop_var</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">min_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">extent</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kind</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">thread_binding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">annotations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.For" title="永久链接至目标">¶</a></dt>
<dd><p>For node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loop_var</strong> (<a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a>) – The loop variable.</p></li>
<li><p><strong>min_val</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The beginning value.</p></li>
<li><p><strong>extent</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The length of the loop.</p></li>
<li><p><strong>kind</strong> (<a class="reference internal" href="#tvm.tir.ForKind" title="tvm.tir.ForKind"><em>ForKind</em></a>) – The type of the for.</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The body statement.</p></li>
<li><p><strong>thread_binding</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="#tvm.tir.IterVar" title="tvm.tir.IterVar"><em>tir.IterVar</em></a><em>]</em>) – The thread this loop binds to. Only valid
if kind is ThreadBinding</p></li>
<li><p><strong>annotations</strong> (<a class="reference internal" href="ir.html#tvm.ir.Map" title="tvm.ir.Map"><em>tvm.ir.Map</em></a>) – Additional annotation hints.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.While">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">While</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">condition</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.While" title="永久链接至目标">¶</a></dt>
<dd><p>While node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>condition</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The termination condition.</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The body statement.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.BufferStore">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">BufferStore</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">buffer</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indices</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.BufferStore" title="永久链接至目标">¶</a></dt>
<dd><p>Buffer store node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>buffer</strong> (<a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a>) – The buffer.</p></li>
<li><p><strong>value</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The value we to be stored.</p></li>
<li><p><strong>indices</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a><em>]</em>) – The indices location to be stored.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.BufferRealize">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">BufferRealize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">buffer</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bounds</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">condition</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.BufferRealize" title="永久链接至目标">¶</a></dt>
<dd><p>Buffer realize node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>buffer</strong> (<a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a>) – The buffer.</p></li>
<li><p><strong>bounds</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Range" title="tvm.ir.Range"><em>Range</em></a><em>]</em>) – The value we to be stored.</p></li>
<li><p><strong>condition</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The realize condition.</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The body of the statement.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Store">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Store</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">buffer_var</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">predicate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Store" title="永久链接至目标">¶</a></dt>
<dd><p>Store node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>buffer_var</strong> (<a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a>) – The buffer Variable.</p></li>
<li><p><strong>value</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The value we want to store.</p></li>
<li><p><strong>index</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The index in the store expression.</p></li>
<li><p><strong>predicate</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The store predicate.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.ProducerStore">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">ProducerStore</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">producer</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indices</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.ProducerStore" title="永久链接至目标">¶</a></dt>
<dd><p>ProducerStore node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>producer</strong> (<a class="reference internal" href="#tvm.tir.DataProducer" title="tvm.tir.DataProducer"><em>DataProducer</em></a>) – The data producer.</p></li>
<li><p><strong>value</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The value to be stored.</p></li>
<li><p><strong>indices</strong> (<em>list of Expr</em>) – The index arguments of the store.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Allocate">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Allocate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">buffer_var</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">extents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">condition</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">annotations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Allocate" title="永久链接至目标">¶</a></dt>
<dd><p>Allocate node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>buffer_var</strong> (<a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a>) – The buffer variable.</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type of the buffer.</p></li>
<li><p><strong>extents</strong> (<em>list of Expr</em>) – The extents of the allocate</p></li>
<li><p><strong>condition</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The condition.</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The body statement.</p></li>
<li><p><strong>annotations</strong> (<em>Optional</em><em>[</em><em>Mapping</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="runtime.html#tvm.runtime.Object" title="tvm.runtime.Object"><em>Object</em></a><em>]</em><em>]</em>) – Additional annotation hints</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.AttrStmt">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">AttrStmt</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">node</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attr_key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.AttrStmt" title="永久链接至目标">¶</a></dt>
<dd><p>AttrStmt node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>node</strong> (<a class="reference internal" href="ir.html#tvm.ir.Node" title="tvm.ir.Node"><em>Node</em></a>) – The node to annotate the attribute</p></li>
<li><p><strong>attr_key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – Attribute type key.</p></li>
<li><p><strong>value</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The value of the attribute</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The body statement.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.ProducerRealize">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">ProducerRealize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">producer</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bounds</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">condition</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">storage_scope</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.ProducerRealize" title="永久链接至目标">¶</a></dt>
<dd><p>ProducerRealize node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>producer</strong> (<a class="reference internal" href="#tvm.tir.DataProducer" title="tvm.tir.DataProducer"><em>DataProducer</em></a>) – The data producer.</p></li>
<li><p><strong>bounds</strong> (<em>list of range</em>) – The bound of realize</p></li>
<li><p><strong>condition</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The realize condition.</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The realize body</p></li>
<li><p><strong>storage_scope</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The storage scope associated with this realization</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.SeqStmt">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">SeqStmt</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seq</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.SeqStmt" title="永久链接至目标">¶</a></dt>
<dd><p>Sequence of statements.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>seq</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a><em>]</em>) – The statements</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.IfThenElse">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">IfThenElse</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">condition</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">then_case</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">else_case</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.IfThenElse" title="永久链接至目标">¶</a></dt>
<dd><p>IfThenElse node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>condition</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The expression</p></li>
<li><p><strong>then_case</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The statement to execute if condition is true.</p></li>
<li><p><strong>else_case</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The statement to execute if condition is false.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Evaluate">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Evaluate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Evaluate" title="永久链接至目标">¶</a></dt>
<dd><p>Evaluate node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The expression to be evalued.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Prefetch">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Prefetch</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">buffer</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bounds</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Prefetch" title="永久链接至目标">¶</a></dt>
<dd><p>Prefetch node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>buffer</strong> (<a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a>) – The buffer to be prefetched.</p></li>
<li><p><strong>bounds</strong> (<em>list of Range</em>) – The bounds to be prefetched.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.stmt_seq">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">stmt_seq</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.stmt_seq" title="永久链接至目标">¶</a></dt>
<dd><p>Make sequence of statements</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>args</strong> (<em>list of Expr</em><em> or </em><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a>) – List of statements to be combined as sequence.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>stmt</strong> – The combined statement.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt">Stmt</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.stmt_list">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">stmt_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stmt</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.stmt_list" title="永久链接至目标">¶</a></dt>
<dd><p>Make list of stmt from blocks.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>stmt</strong> (<em>A block statement</em>) – </p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>stmt_list</strong> – The unpacked list of statements</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>list of Stmt</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.BufferRegion">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">BufferRegion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">buffer</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.buffer.Buffer"><span class="pre">tvm.tir.buffer.Buffer</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">region</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.Range" title="tvm.ir.expr.Range"><span class="pre">tvm.ir.expr.Range</span></a><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.BufferRegion" title="永久链接至目标">¶</a></dt>
<dd><p>BufferRegion node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>buffer</strong> (<a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a>) – The buffer of the buffer region</p></li>
<li><p><strong>region</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Range" title="tvm.ir.Range"><em>Range</em></a><em>]</em>) – The region array of the buffer region</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.MatchBufferRegion">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">MatchBufferRegion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">buffer</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.buffer.Buffer"><span class="pre">tvm.tir.buffer.Buffer</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">source</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.stmt.BufferRegion"><span class="pre">tvm.tir.stmt.BufferRegion</span></a></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.MatchBufferRegion" title="永久链接至目标">¶</a></dt>
<dd><p>MatchBufferRegion node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>buffer</strong> (<a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a>) – The target buffer</p></li>
<li><p><strong>source</strong> (<a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.BufferRegion"><em>BufferRegion</em></a>) – The region of source buffer</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Block">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Block</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">iter_vars</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.IterVar" title="tvm.tir.expr.IterVar"><span class="pre">tvm.tir.expr.IterVar</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reads</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.stmt.BufferRegion"><span class="pre">tvm.tir.stmt.BufferRegion</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">writes</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.stmt.BufferRegion"><span class="pre">tvm.tir.stmt.BufferRegion</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name_hint</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.stmt.Stmt"><span class="pre">tvm.tir.stmt.Stmt</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">init</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.stmt.Stmt"><span class="pre">tvm.tir.stmt.Stmt</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alloc_buffers</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.buffer.Buffer"><span class="pre">tvm.tir.buffer.Buffer</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">match_buffers</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.MatchBufferRegion" title="tvm.tir.stmt.MatchBufferRegion"><span class="pre">tvm.tir.stmt.MatchBufferRegion</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">annotations</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">Mapping</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="runtime.html#tvm.runtime.Object" title="tvm.runtime.object.Object"><span class="pre">tvm.runtime.object.Object</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.base.Span"><span class="pre">tvm.ir.base.Span</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Block" title="永久链接至目标">¶</a></dt>
<dd><p>Block node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>iter_vars</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.tir.IterVar" title="tvm.tir.IterVar"><em>IterVar</em></a><em>]</em>) – The block Variable.</p></li>
<li><p><strong>reads</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.BufferRegion"><em>BufferRegion</em></a><em>]</em>) – The read buffer regions of the block.</p></li>
<li><p><strong>writes</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.BufferRegion"><em>BufferRegion</em></a><em>]</em>) – The write buffer regions of the block.</p></li>
<li><p><strong>name_hint</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – the name_hint of the block.</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The body of the block.</p></li>
<li><p><strong>init</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a><em>]</em>) – The init block of the reduction block</p></li>
<li><p><strong>alloc_buffers</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)"><em>list</em></a><em>[</em><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a><em>]</em><em>]</em>) – The buffer allocations</p></li>
<li><p><strong>match_buffers</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.tir.MatchBufferRegion" title="tvm.tir.MatchBufferRegion"><em>MatchBufferRegion</em></a><em>]</em><em>]</em>) – The subregion buffer match</p></li>
<li><p><strong>annotations</strong> (<em>Optional</em><em>[</em><em>Mapping</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="runtime.html#tvm.runtime.Object" title="tvm.runtime.Object"><em>Object</em></a><em>]</em><em>]</em>) – Additional annotation hints.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this block in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.BlockRealize">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">BlockRealize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">iter_values</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.expr.PrimExpr"><span class="pre">tvm.ir.expr.PrimExpr</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">predicate</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.expr.PrimExpr"><span class="pre">tvm.ir.expr.PrimExpr</span></a><span class="p"><span class="pre">,</span> </span><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><span class="pre">bool</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.stmt.Block"><span class="pre">tvm.tir.stmt.Block</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.base.Span"><span class="pre">tvm.ir.base.Span</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.BlockRealize" title="永久链接至目标">¶</a></dt>
<dd><p>BlockRealize node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>iter_values</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a><em>]</em>) – The binding values of the block var.</p></li>
<li><p><strong>predicate</strong> (<em>Union</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a><em>]</em>) – The predicate of the block.</p></li>
<li><p><strong>block</strong> (<a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.Block"><em>Block</em></a>) – The block to realize</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this block_realize in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.PrimFunc">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">PrimFunc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">params</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ret_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">buffer_map</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.PrimFunc" title="永久链接至目标">¶</a></dt>
<dd><p>A function declaration expression.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>params</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>Union</em><em>[</em><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>tvm.tir.Var</em></a><em>, </em><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>tvm.tir.Buffer</em></a><em>]</em><em>]</em>) – List of input parameters to the function.</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>tvm.tir.Stmt</em></a>) – The body of the function.</p></li>
<li><p><strong>ret_type</strong> (<a class="reference internal" href="ir.html#tvm.ir.Type" title="tvm.ir.Type"><em>tvm.ir.Type</em></a>) – The return type annotation of the function.</p></li>
<li><p><strong>buffer_map</strong> (<a class="reference internal" href="ir.html#tvm.ir.Map" title="tvm.ir.Map"><em>Map</em></a><em>[</em><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>tvm.tir.Var</em></a><em>, </em><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>tvm.tir.Buffer</em></a><em>]</em>) – The buffer binding map.</p></li>
<li><p><strong>attrs</strong> (<em>Optional</em><em>[</em><em>tvm.Attrs</em><em>]</em>) – Attributes of the function, can be None</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.PrimFunc.with_body" title="tvm.tir.PrimFunc.with_body"><code class="xref py py-obj docutils literal notranslate"><span class="pre">with_body</span></code></a>(new_body[, span])</p></td>
<td><p>Create a new PrimFunc with the same set signatures but a new body.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.PrimFunc.specialize" title="tvm.tir.PrimFunc.specialize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">specialize</span></code></a>(param_map)</p></td>
<td><p>Specialize parameters of PrimFunc</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.PrimFunc.script" title="tvm.tir.PrimFunc.script"><code class="xref py py-obj docutils literal notranslate"><span class="pre">script</span></code></a>([tir_prefix, show_meta])</p></td>
<td><p>Print IRModule into TVMScript</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.PrimFunc.with_body">
<span class="sig-name descname"><span class="pre">with_body</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">new_body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.PrimFunc.with_body" title="永久链接至目标">¶</a></dt>
<dd><p>Create a new PrimFunc with the same set signatures but a new body.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>new_body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The new body.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>new_func</strong> – The created new function.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc">PrimFunc</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.PrimFunc.specialize">
<span class="sig-name descname"><span class="pre">specialize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">param_map</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Mapping</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.expr.Var"><span class="pre">tvm.tir.expr.Var</span></a><span class="p"><span class="pre">,</span> </span><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.expr.PrimExpr"><span class="pre">tvm.ir.expr.PrimExpr</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.buffer.Buffer"><span class="pre">tvm.tir.buffer.Buffer</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.PrimFunc.specialize" title="永久链接至目标">¶</a></dt>
<dd><p>Specialize parameters of PrimFunc</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>param_map</strong> (<em>Mapping</em><em>[</em><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a><em>, </em><em>Union</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a><em>, </em><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a><em>]</em><em>]</em>) – The mapping from function params to the instance</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>We can define a Meta TIR function with symbolic shape:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">mem_copy</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">m</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">int32</span><span class="p">,</span> <span class="n">n</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">int32</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>

    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">],</span> <span class="s2">&quot;&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span>
</pre></div>
</div>
<p>Then we can make it specialized with given shapes or buffers.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">a</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">n</span> <span class="o">=</span> <span class="n">mem_copy</span><span class="o">.</span><span class="n">params</span>
<span class="n">func</span> <span class="o">=</span> <span class="n">mem_copy</span><span class="o">.</span><span class="n">specialize</span><span class="p">({</span><span class="n">a</span><span class="p">:</span> <span class="n">tir</span><span class="o">.</span><span class="n">decl_buffer</span><span class="p">((</span><span class="mi">16</span><span class="p">,</span> <span class="mi">16</span><span class="p">))})</span>
<span class="c1"># or</span>
<span class="n">func</span> <span class="o">=</span> <span class="n">mem_copy</span><span class="o">.</span><span class="n">specialize</span><span class="p">({</span><span class="n">n</span><span class="p">:</span> <span class="mi">16</span><span class="p">,</span> <span class="n">m</span><span class="p">:</span> <span class="mi">16</span><span class="p">})</span>
</pre></div>
</div>
<p>The specialized function:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">mem_copy_16_16</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">16</span><span class="p">,</span> <span class="mi">16</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">16</span><span class="p">,</span> <span class="mi">16</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>

    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">16</span><span class="p">,</span> <span class="mi">16</span><span class="p">],</span> <span class="s2">&quot;&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>func</strong> – The new function with parameter specialized</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc">PrimFunc</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.PrimFunc.script">
<span class="sig-name descname"><span class="pre">script</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tir_prefix</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">'tir'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_meta</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><span class="pre">bool</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></span><a class="headerlink" href="#tvm.tir.PrimFunc.script" title="永久链接至目标">¶</a></dt>
<dd><p>Print IRModule into TVMScript</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tir_prefix</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The tir namespace prefix</p></li>
<li><p><strong>show_meta</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether to show meta information</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>script</strong> – The TVM Script of the PrimFunc</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a></p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.call_packed">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">call_packed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.call_packed" title="永久链接至目标">¶</a></dt>
<dd><p>Build expression by call an external packed function.</p>
<p>The argument to packed function can be Expr or Buffer.
The argument is the corresponding POD type when Expr is presented.</p>
<p>When the argument is Buffer, the corresponding PackedFunc
will recieve an TVMArrayHandle whose content is valid during the callback period.
If the PackedFunc is a python callback, then the corresponding argument is NDArray.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>args</strong> (<em>list of Expr</em><em> or </em><em>Buffer.</em>) – Positional arguments.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>call</strong> – The call expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<dl class="simple">
<dt><code class="xref py py-obj docutils literal notranslate"><span class="pre">te.extern</span></code></dt><dd><p>Create tensor with extern function call.</p>
</dd>
</dl>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.call_intrin">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">call_intrin</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func_name</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.call_intrin" title="永久链接至目标">¶</a></dt>
<dd><p>Build expression by calling an intrinsic function.</p>
<p>Intrinsics can be overloaded with multiple data types via
the intrinsic translation rule.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type of the result.</p></li>
<li><p><strong>func_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The intrinsic function name.</p></li>
<li><p><strong>args</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)"><em>list</em></a>) – Positional arguments.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>call</strong> – The call expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.call_pure_extern">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">call_pure_extern</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func_name</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.call_pure_extern" title="永久链接至目标">¶</a></dt>
<dd><p>Build expression by calling a pure extern function.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type of the result.</p></li>
<li><p><strong>func_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The extern function name.</p></li>
<li><p><strong>args</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)"><em>list</em></a>) – Positional arguments.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>call</strong> – The call expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.call_extern">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">call_extern</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func_name</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.call_extern" title="永久链接至目标">¶</a></dt>
<dd><p>Build expression by calling a extern function.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type of the result.</p></li>
<li><p><strong>func_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The extern function name.</p></li>
<li><p><strong>args</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)"><em>list</em></a>) – Positional arguments.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>call</strong> – The call expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.call_llvm_intrin">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">call_llvm_intrin</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.call_llvm_intrin" title="永久链接至目标">¶</a></dt>
<dd><p>Build expression by calling a llvm intrinsic function</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type of the result.</p></li>
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name of the llvm intrinsic function.</p></li>
<li><p><strong>args</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)"><em>list</em></a>) – Poistional arguments.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>call</strong> – The call expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.call_llvm_pure_intrin">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">call_llvm_pure_intrin</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.call_llvm_pure_intrin" title="永久链接至目标">¶</a></dt>
<dd><p>Build expression by calling a pure llvm intrinsic function</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type of the result.</p></li>
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name of the llvm intrinsic function.</p></li>
<li><p><strong>args</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)"><em>list</em></a>) – Poistional arguments.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>call</strong> – The call expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.ret">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">ret</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">val</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.ret" title="永久链接至目标">¶</a></dt>
<dd><p>Create a tir return expression</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>val</strong> (<em>Expr</em>) – The returned tir expression, whose data type is int, float or void pointer.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>ret</strong> – The return expression</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.all">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">all</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.all" title="永久链接至目标">¶</a></dt>
<dd><dl class="simple">
<dt>Create a new expression of the intersection of all conditions in the</dt><dd><p>arguments</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>args</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)"><em>list</em></a>) – List of symbolic boolean expressions</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>expr</strong> – Expression</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.any">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">any</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.any" title="永久链接至目标">¶</a></dt>
<dd><p>Create a new experssion of the union of all conditions in the arguments</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>args</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)"><em>list</em></a>) – List of symbolic boolean expressions</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>expr</strong> – Expression</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.min_value">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">min_value</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.min_value" title="永久链接至目标">¶</a></dt>
<dd><p>minimum value of dtype</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>value</strong> – The minimum value of dtype.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>tvm.Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.max_value">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">max_value</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.base.Span"><span class="pre">tvm.ir.base.Span</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#tvm.tir.Any" title="tvm.tir.Any"><span class="pre">Any</span></a></span></span><a class="headerlink" href="#tvm.tir.max_value" title="永久链接至目标">¶</a></dt>
<dd><p>maximum value of dtype</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>value</strong> – The maximum value of dtype.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>tvm.Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.trace">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">trace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">trace_action</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'tvm.default_trace_action'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.trace" title="永久链接至目标">¶</a></dt>
<dd><p>Trace tensor data at the runtime.</p>
<p>The trace function allows to trace specific tensor at the
runtime. The tracing value should come as last argument.
The trace action should be specified, by default
tvm.default_trace_action is used.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>args</strong> (<em>list of Expr</em><em> or </em><em>Buffers.</em>) – Positional arguments.</p></li>
<li><p><strong>trace_action</strong> (<em>str.</em>) – The name of the trace action.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>call</strong> – The call expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<dl class="simple">
<dt><a class="reference internal" href="#tvm.tir.call_packed" title="tvm.tir.call_packed"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tvm.tir.call_packed</span></code></a></dt><dd><p>Creates packed function.</p>
</dd>
</dl>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.exp">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">exp</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.exp" title="永久链接至目标">¶</a></dt>
<dd><p>Take exponential of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.exp2">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">exp2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.exp2" title="永久链接至目标">¶</a></dt>
<dd><p>Calculate 2**x</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.exp10">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">exp10</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.exp10" title="永久链接至目标">¶</a></dt>
<dd><p>Calculate 10**x</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.log">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">log</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.log" title="永久链接至目标">¶</a></dt>
<dd><p>Take log of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.log2">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">log2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.log2" title="永久链接至目标">¶</a></dt>
<dd><p>Take log2 of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.log10">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">log10</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.log10" title="永久链接至目标">¶</a></dt>
<dd><p>Take log10 of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.log1p">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">log1p</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.log1p" title="永久链接至目标">¶</a></dt>
<dd><p>Take log(x + 1) with respect to input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.ldexp">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">ldexp</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.ldexp" title="永久链接至目标">¶</a></dt>
<dd><p>Returns x1 * (2 ** x2).</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x1</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>x2</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.clz">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">clz</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.clz" title="永久链接至目标">¶</a></dt>
<dd><p>Count leading zero bits of an integer x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input 32 or 64 bit integer.
The result is undefined if the input is 0.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.sin">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">sin</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.sin" title="永久链接至目标">¶</a></dt>
<dd><p>Take sin of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.sinh">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">sinh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.sinh" title="永久链接至目标">¶</a></dt>
<dd><p>Take sinh of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.asin">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">asin</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.asin" title="永久链接至目标">¶</a></dt>
<dd><p>Take asin of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.asinh">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">asinh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.asinh" title="永久链接至目标">¶</a></dt>
<dd><p>Take asinh of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.cos">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">cos</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.cos" title="永久链接至目标">¶</a></dt>
<dd><p>Take cos of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.cosh">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">cosh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.cosh" title="永久链接至目标">¶</a></dt>
<dd><p>Take cosh of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.acos">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">acos</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.acos" title="永久链接至目标">¶</a></dt>
<dd><p>Take acos of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.acosh">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">acosh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.acosh" title="永久链接至目标">¶</a></dt>
<dd><p>Take acos of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.tan">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">tan</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.tan" title="永久链接至目标">¶</a></dt>
<dd><p>Take tan of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.tanh">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">tanh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.tanh" title="永久链接至目标">¶</a></dt>
<dd><p>Take hyperbolic tanh of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.atan">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">atan</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.atan" title="永久链接至目标">¶</a></dt>
<dd><p>Take atan of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.atan2">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">atan2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.atan2" title="永久链接至目标">¶</a></dt>
<dd><p>Take arctan2(x1, x2).</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x1</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>x2</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.atanh">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">atanh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.atanh" title="永久链接至目标">¶</a></dt>
<dd><p>Take atanh of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.erf">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">erf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.erf" title="永久链接至目标">¶</a></dt>
<dd><p>Take gauss error function of the input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.sigmoid">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">sigmoid</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.sigmoid" title="永久链接至目标">¶</a></dt>
<dd><p>Quick function to get sigmoid</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.sqrt">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">sqrt</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.sqrt" title="永久链接至目标">¶</a></dt>
<dd><p>Take square root of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.rsqrt">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">rsqrt</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.rsqrt" title="永久链接至目标">¶</a></dt>
<dd><p>Take reciprocal of square root of input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.floor">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">floor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.expr.PrimExprWithOp</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.floor" title="永久链接至目标">¶</a></dt>
<dd><p>Take floor of float input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.ceil">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">ceil</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.ceil" title="永久链接至目标">¶</a></dt>
<dd><p>Take ceil of float input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.hypot">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">hypot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.hypot" title="永久链接至目标">¶</a></dt>
<dd><p>Equivalent to sqrt(x1**2 + x2**2), element-wise.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x1</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>x2</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.trunc">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">trunc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.trunc" title="永久链接至目标">¶</a></dt>
<dd><p>Get truncated value of the input.</p>
<p>The truncated value of the scalar x is the
nearest integer i which is closer to zero than x is.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.abs">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">abs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.abs" title="永久链接至目标">¶</a></dt>
<dd><p>Get absolute value of the input element-wise.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.round">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">round</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.round" title="永久链接至目标">¶</a></dt>
<dd><p>Round elements of the array to the nearest integer.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.nextafter">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">nextafter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.nextafter" title="永久链接至目标">¶</a></dt>
<dd><p>Return the next floating-point value after x1 towards x2.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x1</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>x2</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.nearbyint">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">nearbyint</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.nearbyint" title="永久链接至目标">¶</a></dt>
<dd><p>Round elements of the array to the nearest integer.
This intrinsic uses llvm.nearbyint instead of llvm.round
which is faster but will results different from te.round.
Notably nearbyint rounds according to the rounding mode,
whereas te.round (llvm.round) ignores that.
For differences between the two see:
<a class="reference external" href="https://en.cppreference.com/w/cpp/numeric/math/round">https://en.cppreference.com/w/cpp/numeric/math/round</a>
<a class="reference external" href="https://en.cppreference.com/w/cpp/numeric/math/nearbyint">https://en.cppreference.com/w/cpp/numeric/math/nearbyint</a></p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.power">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">power</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.power" title="永久链接至目标">¶</a></dt>
<dd><p>x power y</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>y</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The exponent</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>z</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.popcount">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">popcount</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.popcount" title="永久链接至目标">¶</a></dt>
<dd><p>Count the number of set bits in input x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.fmod">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">fmod</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.fmod" title="永久链接至目标">¶</a></dt>
<dd><p>Return the remainder of x divided by y with the same sign as x.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>y</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>z</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.if_then_else">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">if_then_else</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cond</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">t</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.if_then_else" title="永久链接至目标">¶</a></dt>
<dd><p>Conditional selection expression.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cond</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The condition</p></li>
<li><p><strong>t</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The result expression if cond is true.</p></li>
<li><p><strong>f</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The result expression if cond is false.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The result of conditional expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.Node" title="tvm.ir.Node">Node</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>Unlike Select, if_then_else will not execute
the branch that does not satisfy the condition.
You can use it to guard against out of bound access.
Unlike Select, if_then_else cannot be vectorized
if some lanes in the vector have different conditions.</p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.isnan">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">isnan</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.isnan" title="永久链接至目标">¶</a></dt>
<dd><p>Check if input value is Nan.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.isfinite">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">isfinite</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.isfinite" title="永久链接至目标">¶</a></dt>
<dd><p>Check if input value is finite.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.isinf">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">isinf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.isinf" title="永久链接至目标">¶</a></dt>
<dd><p>Check if input value is infinite.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.copysign">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">copysign</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.copysign" title="永久链接至目标">¶</a></dt>
<dd><p>Change the sign of x1 to that of x2, element-wise.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x1</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
<li><p><strong>x2</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Input argument.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.div">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">div</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.div" title="永久链接至目标">¶</a></dt>
<dd><p>Compute a / b as in C/C++ semantics.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand, known to be non-negative.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand, known to be non-negative.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>res</strong> – The result expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>When operands are integers, returns truncdiv(a, b, span).</p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.indexdiv">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">indexdiv</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.indexdiv" title="永久链接至目标">¶</a></dt>
<dd><p>Compute floor(a / b) where a and b are non-negative.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand, known to be non-negative.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand, known to be non-negative.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>res</strong> – The result expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>Use this function to split non-negative indices.
This function may take advantage of operands’
non-negativeness.</p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.indexmod">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">indexmod</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.indexmod" title="永久链接至目标">¶</a></dt>
<dd><p>Compute the remainder of indexdiv. a and b are non-negative.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand, known to be non-negative.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand, known to be non-negative.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>res</strong> – The result expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>Use this function to split non-negative indices.
This function may take advantage of operands’
non-negativeness.</p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.truncdiv">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">truncdiv</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.truncdiv" title="永久链接至目标">¶</a></dt>
<dd><p>Compute the truncdiv of two expressions.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>res</strong> – The result expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>This is the default integer division behavior in C.</p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.truncmod">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">truncmod</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.truncmod" title="永久链接至目标">¶</a></dt>
<dd><p>Compute the truncmod of two expressions.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>res</strong> – The result expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>This is the default integer division behavior in C.</p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.floordiv">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">floordiv</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.floordiv" title="永久链接至目标">¶</a></dt>
<dd><p>Compute the floordiv of two expressions.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>res</strong> – The result expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.floormod">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">floormod</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.floormod" title="永久链接至目标">¶</a></dt>
<dd><p>Compute the floormod of two expressions.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left hand operand</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right hand operand</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this operator in the source.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>res</strong> – The result expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.comm_reducer">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">comm_reducer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fcombine</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fidentity</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'reduce'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.comm_reducer" title="永久链接至目标">¶</a></dt>
<dd><p>Create a commutative reducer for reduction.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>fcombine</strong> (<em>function</em><em>(</em><em>Expr -&gt; Expr -&gt; Expr</em><em>)</em>) – A binary function which takes two Expr as input to return a Expr.</p></li>
<li><p><strong>fidentity</strong> (<em>function</em><em>(</em><em>str -&gt; Expr</em><em>)</em>) – A function which takes a type string as input to return a const Expr.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><p><strong>reducer</strong> – A function which creates a reduce expression over axis.
There are two ways to use it:</p>
<ol class="arabic simple">
<li><p>accept (expr, axis, where) to produce an Reduce Expr on
specified axis;</p></li>
<li><p>simply use it with multiple Exprs.</p></li>
</ol>
</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>function</p>
</dd>
</dl>
<p class="rubric">示例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">n</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;n&quot;</span><span class="p">)</span>
<span class="n">m</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;m&quot;</span><span class="p">)</span>
<span class="n">mysum</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">comm_reducer</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span><span class="o">+</span><span class="n">y</span><span class="p">,</span>
    <span class="k">lambda</span> <span class="n">t</span><span class="p">:</span> <span class="n">tvm</span><span class="o">.</span><span class="n">tir</span><span class="o">.</span><span class="n">const</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">t</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;mysum&quot;</span><span class="p">)</span>
<span class="n">A</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">placeholder</span><span class="p">((</span><span class="n">n</span><span class="p">,</span> <span class="n">m</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;A&quot;</span><span class="p">)</span>
<span class="n">k</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">reduce_axis</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="n">m</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;k&quot;</span><span class="p">)</span>
<span class="n">B</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">compute</span><span class="p">((</span><span class="n">n</span><span class="p">,),</span> <span class="k">lambda</span> <span class="n">i</span><span class="p">:</span> <span class="n">mysum</span><span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">k</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="n">k</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;B&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.min">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">min</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axis</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">where</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">init</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.min" title="永久链接至目标">¶</a></dt>
<dd><p>Create a min expression over axis.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>expr</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The source expression.</p></li>
<li><p><strong>axis</strong> (<a class="reference internal" href="#tvm.tir.IterVar" title="tvm.tir.IterVar"><em>IterVar</em></a>) – The reduction IterVar axis</p></li>
<li><p><strong>where</strong> (<em>optional</em><em>, </em><em>Expr</em>) – Filtering predicate of the reduction.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>value</strong> – The result value.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
<p class="rubric">示例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">m</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;m&quot;</span><span class="p">)</span>
<span class="n">n</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;n&quot;</span><span class="p">)</span>
<span class="n">A</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">placeholder</span><span class="p">((</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;A&quot;</span><span class="p">)</span>
<span class="n">k</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">reduce_axis</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;k&quot;</span><span class="p">)</span>

<span class="c1"># there are two way to use this min reducer:</span>
<span class="c1"># mode 1, accept (expr, axis, where) to produce an Reduce Expr</span>
<span class="c1"># tvm.min represents tvm.te.min or tvm.tir.min.</span>
<span class="n">B</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">compute</span><span class="p">((</span><span class="n">m</span><span class="p">,),</span> <span class="k">lambda</span> <span class="n">i</span><span class="p">:</span> <span class="n">tvm</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">k</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="n">k</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;B&quot;</span><span class="p">)</span>

<span class="c1"># mode 2, simply use it with multiple Exprs:</span>
<span class="n">min_res</span> <span class="o">=</span> <span class="n">tvm</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.max">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">max</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axis</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">where</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">init</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.max" title="永久链接至目标">¶</a></dt>
<dd><p>Create a max expression over axis.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>expr</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The source expression.</p></li>
<li><p><strong>axis</strong> (<a class="reference internal" href="#tvm.tir.IterVar" title="tvm.tir.IterVar"><em>IterVar</em></a>) – The reduction IterVar axis</p></li>
<li><p><strong>where</strong> (<em>optional</em><em>, </em><em>Expr</em>) – Filtering predicate of the reduction.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>value</strong> – The result value.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
<p class="rubric">示例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">m</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;m&quot;</span><span class="p">)</span>
<span class="n">n</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;n&quot;</span><span class="p">)</span>
<span class="n">A</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">placeholder</span><span class="p">((</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;A&quot;</span><span class="p">)</span>
<span class="n">k</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">reduce_axis</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;k&quot;</span><span class="p">)</span>

<span class="c1"># there are two way to use this max reducer:</span>
<span class="c1"># mode 1, accept (expr, axis, where) to produce an Reduce Expr</span>
<span class="c1"># tvm.max represents tvm.te.max or tvm.tir.max.</span>
<span class="n">B</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">compute</span><span class="p">((</span><span class="n">m</span><span class="p">,),</span> <span class="k">lambda</span> <span class="n">i</span><span class="p">:</span> <span class="n">tvm</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">k</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="n">k</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;B&quot;</span><span class="p">)</span>

<span class="c1"># mode 2, simply use it with multiple Exprs:</span>
<span class="n">max_res</span> <span class="o">=</span> <span class="n">tvm</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.sum">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">sum</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axis</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">where</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">init</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.sum" title="永久链接至目标">¶</a></dt>
<dd><p>Create a sum expression over axis.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>expr</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The source expression.</p></li>
<li><p><strong>axis</strong> (<a class="reference internal" href="#tvm.tir.IterVar" title="tvm.tir.IterVar"><em>IterVar</em></a>) – The reduction IterVar axis</p></li>
<li><p><strong>where</strong> (<em>optional</em><em>, </em><em>Expr</em>) – Filtering predicate of the reduction.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>value</strong> – The result value.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
<p class="rubric">示例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">m</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;m&quot;</span><span class="p">)</span>
<span class="n">n</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;n&quot;</span><span class="p">)</span>
<span class="n">A</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">placeholder</span><span class="p">((</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;A&quot;</span><span class="p">)</span>
<span class="n">k</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">reduce_axis</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;k&quot;</span><span class="p">)</span>

<span class="c1"># there are two way to use this sum reducer:</span>
<span class="c1"># mode 1, accept (expr, axis, where) to produce an Reduce Expr</span>
<span class="c1"># tvm.sum represents tvm.te.sum or tvm.tir.sum.</span>
<span class="n">B</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">compute</span><span class="p">((</span><span class="n">m</span><span class="p">,),</span> <span class="k">lambda</span> <span class="n">i</span><span class="p">:</span> <span class="n">tvm</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">k</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="n">k</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;B&quot;</span><span class="p">)</span>

<span class="c1"># mode 2, simply use it with multiple Exprs:</span>
<span class="n">sum_res</span> <span class="o">=</span> <span class="n">tvm</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.q_multiply_shift">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">q_multiply_shift</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">q</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.q_multiply_shift" title="永久链接至目标">¶</a></dt>
<dd><p>Execute a multiplication between two Q-numbers x and y
followed by a right shift s. The mathematical expression is:</p>
<blockquote>
<div><p>out = round(x*y*2^-s)</p>
</div></blockquote>
<p>More about Q-numbers here: <a class="reference external" href="https://en.wikipedia.org/wiki/Q_(number_format">https://en.wikipedia.org/wiki/Q_(number_format</a>)
The rounding rule is to the nearest value, rounding half up
(i.e., round(x.1) = x and round (x.5) = x+1)</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – First Q-number</p></li>
<li><p><strong>y</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Second Q-number</p></li>
<li><p><strong>q</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Number of fractional bits in x and y. Needs to be &gt; 0</p></li>
<li><p><strong>s</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – Integer shift</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>y</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.StmtSRef">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">StmtSRef</span></span><a class="headerlink" href="#tvm.tir.StmtSRef" title="永久链接至目标">¶</a></dt>
<dd><p>An object that refers to schedulable elements in the TensorIR, aka “sref”.</p>
<p>Glossary
- Block sref: An StmtSref that points to a TensorIR block.
- Loop sref: An StmtSRef that points to a TensorIR for loop.
- Parent sref: The parent sref of an sref is the block/loop sref that points to its closest
schedulable statement of its ancestors on the TensorIR AST.
- Root sref: Sref to the root block. Every sref has exactly one parent sref
except for root sref.
- Sref tree: The parent-children-relationship of srefs that forms a tree,
uniquely determined by the TensorIR AST.</p>
<p><strong>Attributes:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.StmtSRef.stmt" title="tvm.tir.StmtSRef.stmt"><code class="xref py py-obj docutils literal notranslate"><span class="pre">stmt</span></code></a></p></td>
<td><p>The block/for stmt the object refers to</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.StmtSRef.parent" title="tvm.tir.StmtSRef.parent"><code class="xref py py-obj docutils literal notranslate"><span class="pre">parent</span></code></a></p></td>
<td><p>The parent sref</p></td>
</tr>
</tbody>
</table>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.StmtSRef.inline_mark" title="tvm.tir.StmtSRef.inline_mark"><code class="xref py py-obj docutils literal notranslate"><span class="pre">inline_mark</span></code></a>()</p></td>
<td><p>A special StmtSRef, which doesn’t point to any stmt in the AST, only serving as a “mark” to hint compute-at to do the work of compute-inline</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.StmtSRef.root_mark" title="tvm.tir.StmtSRef.root_mark"><code class="xref py py-obj docutils literal notranslate"><span class="pre">root_mark</span></code></a>()</p></td>
<td><p>A special StmtSRef, which doesn’t point to any stmt in the AST, only serving as a “mark” to hint compute-at to do nothing</p></td>
</tr>
</tbody>
</table>
<dl class="py property">
<dt class="sig sig-object py" id="tvm.tir.StmtSRef.stmt">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">stmt</span></span><em class="property"><span class="pre">:</span> <span class="pre">Optional[Union[tvm.tir.stmt.Block,</span> <span class="pre">tvm.tir.stmt.For]]</span></em><a class="headerlink" href="#tvm.tir.StmtSRef.stmt" title="永久链接至目标">¶</a></dt>
<dd><p>The block/for stmt the object refers to</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.tir.StmtSRef.parent">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">parent</span></span><em class="property"><span class="pre">:</span> <span class="pre">Optional[tvm.tir.schedule.block_scope.StmtSRef]</span></em><a class="headerlink" href="#tvm.tir.StmtSRef.parent" title="永久链接至目标">¶</a></dt>
<dd><p>The parent sref</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.StmtSRef.inline_mark">
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">inline_mark</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.schedule.block_scope.StmtSRef"><span class="pre">tvm.tir.schedule.block_scope.StmtSRef</span></a></span></span><a class="headerlink" href="#tvm.tir.StmtSRef.inline_mark" title="永久链接至目标">¶</a></dt>
<dd><p>A special StmtSRef, which doesn’t point to any stmt in the AST,
only serving as a “mark” to hint compute-at to do the work of compute-inline</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.StmtSRef.root_mark">
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">root_mark</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.schedule.block_scope.StmtSRef"><span class="pre">tvm.tir.schedule.block_scope.StmtSRef</span></a></span></span><a class="headerlink" href="#tvm.tir.StmtSRef.root_mark" title="永久链接至目标">¶</a></dt>
<dd><p>A special StmtSRef, which doesn’t point to any stmt in the AST,
only serving as a “mark” to hint compute-at to do nothing</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.BlockScope">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">BlockScope</span></span><a class="headerlink" href="#tvm.tir.BlockScope" title="永久链接至目标">¶</a></dt>
<dd><p>An object corresponds to each block sref in the sref tree, which
tracks the producer-consumer dependency between blocks.</p>
<p>Glossary:</p>
<ul class="simple">
<li><p>Block scope: A contiguous subtree of the sref tree, rooted at
each block sref, whose components are:</p>
<ul>
<li><p>scope root: a block sref</p></li>
<li><p>internal srefs: loop srefs</p></li>
<li><p>scope leaves: block srefs</p></li>
</ul>
</li>
<li><p>Child block: The scope leaf blocks under the scope root or a specific internal sref</p></li>
</ul>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.BlockScope.get_deps_by_src" title="tvm.tir.BlockScope.get_deps_by_src"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_deps_by_src</span></code></a>(block)</p></td>
<td><p>Get all dependencies whose <cite>src</cite> is the target`block`.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.BlockScope.get_deps_by_dst" title="tvm.tir.BlockScope.get_deps_by_dst"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_deps_by_dst</span></code></a>(block)</p></td>
<td><p>Get all dependencies whose <cite>dst</cite> is the target <cite>block</cite>.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.BlockScope.get_deps_by_src">
<span class="sig-name descname"><span class="pre">get_deps_by_src</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.schedule.block_scope.StmtSRef"><span class="pre">tvm.tir.schedule.block_scope.StmtSRef</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">tvm.tir.schedule.block_scope.Dependency</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#tvm.tir.BlockScope.get_deps_by_src" title="永久链接至目标">¶</a></dt>
<dd><p>Get all dependencies whose <cite>src</cite> is the target`block`.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>block</strong> (<a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.StmtSRef"><em>StmtSRef</em></a>) – The queried block</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>blocks</strong> – The dependencies</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[Dependency]</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.BlockScope.get_deps_by_dst">
<span class="sig-name descname"><span class="pre">get_deps_by_dst</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.schedule.block_scope.StmtSRef"><span class="pre">tvm.tir.schedule.block_scope.StmtSRef</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">tvm.tir.schedule.block_scope.Dependency</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#tvm.tir.BlockScope.get_deps_by_dst" title="永久链接至目标">¶</a></dt>
<dd><p>Get all dependencies whose <cite>dst</cite> is the target <cite>block</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>block</strong> (<a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.StmtSRef"><em>StmtSRef</em></a>) – The queried block</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>blocks</strong> – The dependencies</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[Dependency]</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.ScheduleState">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">ScheduleState</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.function.PrimFunc"><span class="pre">tvm.tir.function.PrimFunc</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="ir.html#tvm.ir.IRModule" title="tvm.ir.module.IRModule"><span class="pre">tvm.ir.module.IRModule</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">debug_mask</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span> </span><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">'none'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.ScheduleState" title="永久链接至目标">¶</a></dt>
<dd><p>The state of scheduling, which exposes a <cite>Replace</cite> method as
the primary resort for all the scheduling primitives to manipulate the TensorIR.</p>
<p>The data structure contains the following information
1) The AST being scheduled (mod)
2) The sref tree of schedulable statements (indicated by the srefs)
3) The dependency information of each block scope (block_info)
4) A reverse mapping from the AST nodes to that in the sref tree (get_sref)
5) A debug flag, if set, extra checking is enabled (debug_mask)</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>mod</strong> (<a class="reference internal" href="ir.html#tvm.ir.IRModule" title="tvm.ir.IRModule"><em>IRModule</em></a>) – The AST of the module being scheduled</p></li>
<li><p><strong>debug_mask</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Do extra correctness checking after the object construction
and each time after calling the Replace method.</p></li>
</ul>
</dd>
</dl>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.ScheduleState.get_sref" title="tvm.tir.ScheduleState.get_sref"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_sref</span></code></a>(stmt)</p></td>
<td><p>Return the corresponding sref that points to the stmt</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.ScheduleState.get_block_scope" title="tvm.tir.ScheduleState.get_block_scope"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_block_scope</span></code></a>(block_sref)</p></td>
<td><p>Get the BlockScope correpsonding to the block sref</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.ScheduleState.replace" title="tvm.tir.ScheduleState.replace"><code class="xref py py-obj docutils literal notranslate"><span class="pre">replace</span></code></a>(src_sref, tgt_stmt[, block_sref_reuse])</p></td>
<td><p>Replace the part of the AST, as being pointed to by <cite>src_sref</cite>, with a specific statement <cite>tgt_stmt</cite>, and maintain the sref tree accordingly.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.ScheduleState.get_sref">
<span class="sig-name descname"><span class="pre">get_sref</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stmt</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.stmt.Block"><span class="pre">tvm.tir.stmt.Block</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.For" title="tvm.tir.stmt.For"><span class="pre">tvm.tir.stmt.For</span></a><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.schedule.block_scope.StmtSRef"><span class="pre">tvm.tir.schedule.block_scope.StmtSRef</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#tvm.tir.ScheduleState.get_sref" title="永久链接至目标">¶</a></dt>
<dd><p>Return the corresponding sref that points to the stmt</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>stmt</strong> (<em>Union</em><em>[</em><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.Block"><em>Block</em></a><em>, </em><a class="reference internal" href="#tvm.tir.For" title="tvm.tir.For"><em>For</em></a><em>]</em>) – The schedulable statement in the TensorIR to be retrieved for its sref</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>sref</strong> – The corresponding sref</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.StmtSRef">StmtSRef</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.ScheduleState.get_block_scope">
<span class="sig-name descname"><span class="pre">get_block_scope</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block_sref</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.schedule.block_scope.StmtSRef"><span class="pre">tvm.tir.schedule.block_scope.StmtSRef</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#tvm.tir.BlockScope" title="tvm.tir.schedule.block_scope.BlockScope"><span class="pre">tvm.tir.schedule.block_scope.BlockScope</span></a></span></span><a class="headerlink" href="#tvm.tir.ScheduleState.get_block_scope" title="永久链接至目标">¶</a></dt>
<dd><p>Get the BlockScope correpsonding to the block sref</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>block_sref</strong> (<a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.StmtSRef"><em>StmtSRef</em></a>) – The block sref to be retrieved</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>sref</strong> – The corresponding sref</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.StmtSRef">StmtSRef</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.ScheduleState.replace">
<span class="sig-name descname"><span class="pre">replace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">src_sref</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.schedule.block_scope.StmtSRef"><span class="pre">tvm.tir.schedule.block_scope.StmtSRef</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">tgt_stmt</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.stmt.Block"><span class="pre">tvm.tir.stmt.Block</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.For" title="tvm.tir.stmt.For"><span class="pre">tvm.tir.stmt.For</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.BlockRealize" title="tvm.tir.stmt.BlockRealize"><span class="pre">tvm.tir.stmt.BlockRealize</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">block_sref_reuse</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.stmt.Block"><span class="pre">tvm.tir.stmt.Block</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.stmt.Block"><span class="pre">tvm.tir.stmt.Block</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.ScheduleState.replace" title="永久链接至目标">¶</a></dt>
<dd><p>Replace the part of the AST, as being pointed to by <cite>src_sref</cite>,
with a specific statement <cite>tgt_stmt</cite>, and maintain the sref tree accordingly.
Replace will try to perform copy on write as much as possible when the ScheduleState holds
the only copy to the IRModule and IR nodes.</p>
<p>Only 3 types of replacements are allowed: from <cite>src_sref-&gt;stmt</cite> to <cite>tgt_stmt</cite>.
1) Block -&gt; Block
2) Loop -&gt; Loop
3) Loop -&gt; BlockRealize</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>src_sref</strong> (<a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.StmtSRef"><em>StmtSRef</em></a>) – The sref to the statement to be replaced in the TensorIR AST</p></li>
<li><p><strong>tgt_stmt</strong> (<em>Union</em><em>[</em><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.Block"><em>Block</em></a><em>, </em><a class="reference internal" href="#tvm.tir.For" title="tvm.tir.For"><em>For</em></a><em>, </em><a class="reference internal" href="#tvm.tir.BlockRealize" title="tvm.tir.BlockRealize"><em>BlockRealize</em></a><em>]</em>) – The statement to be replaced to</p></li>
<li><p><strong>block_sref_reuse</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.Block"><em>Block</em></a><em>, </em><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.Block"><em>Block</em></a><em>]</em><em>] </em><em>= None</em>) – Maps an old block (to be replaced in the subtree under <cite>src_sref-&gt;stmt</cite>)
to a new block (replaced to, in the subtree under <cite>tgt_stmt</cite>), and enforces
reuse of srefs between them (rather than create new srefs) i.e. after being replaced,
the sref that points to the old block will point to the new one</p></li>
</ul>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>The reuse of loop srefs are detected automatically according to the reuse of loop vars.</p>
</div>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.Schedule">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">Schedule</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.function.PrimFunc"><span class="pre">tvm.tir.function.PrimFunc</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="ir.html#tvm.ir.IRModule" title="tvm.ir.module.IRModule"><span class="pre">tvm.ir.module.IRModule</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">debug_mask</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span> </span><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">'none'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">error_render_level</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">'detail'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.Schedule" title="永久链接至目标">¶</a></dt>
<dd><p>The user-facing schedule class</p>
<p>A schedule is a set of transformations that change the order of computation but
preserve the semantics of computation. Some example of schedules:
1) Split a loop into two;
2) Reorder two loops;
3) Inline the computation of a specific buffer into its consumer</p>
<p>The schedule class stores auxiliary information to schedule correctly and efficiently.</p>
<p>Link to tutorial: <a class="reference external" href="https://tvm.apache.org/docs/tutorials/language/schedule_primitives.html">https://tvm.apache.org/docs/tutorials/language/schedule_primitives.html</a></p>
<p><strong>Attributes:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.mod" title="tvm.tir.Schedule.mod"><code class="xref py py-obj docutils literal notranslate"><span class="pre">mod</span></code></a></p></td>
<td><p>Returns the AST of the module being scheduled</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.state" title="tvm.tir.Schedule.state"><code class="xref py py-obj docutils literal notranslate"><span class="pre">state</span></code></a></p></td>
<td><p>Returns the ScheduleState in the current schedule class</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.trace" title="tvm.tir.Schedule.trace"><code class="xref py py-obj docutils literal notranslate"><span class="pre">trace</span></code></a></p></td>
<td><p>Returns the internally maintained trace of scheduling program execution</p></td>
</tr>
</tbody>
</table>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.copy" title="tvm.tir.Schedule.copy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">copy</span></code></a>()</p></td>
<td><p>Returns a copy of the schedule, including both the state and the symbol table, * guaranteeing that * 1) SRef tree is completely reconstructed; * 2) The IRModule being scheduled is untouched; * 3) All the random variables are valid in the copy, pointing to the corresponding sref * reconstructed</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.seed" title="tvm.tir.Schedule.seed"><code class="xref py py-obj docutils literal notranslate"><span class="pre">seed</span></code></a>(seed)</p></td>
<td><p>Seed the randomness</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.fork_seed" title="tvm.tir.Schedule.fork_seed"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fork_seed</span></code></a>()</p></td>
<td><p>Returns a forked random state as seed for new schedules</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.show" title="tvm.tir.Schedule.show"><code class="xref py py-obj docutils literal notranslate"><span class="pre">show</span></code></a>(rand_var)</p></td>
<td><p>Returns a string representation of the value that the random variable evaluates to</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.get" title="tvm.tir.Schedule.get"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get</span></code></a>(rand_var_or_sref)</p></td>
<td><p>Returns: - the corresponding Block that a BlockRV evaluates to; - the corresponding For that a LoopRV evaluates to; - the corresponding integer that a ExprRV evaluates to; - the corresponding Block that a block sref points to; - the corresponding For that a loop sref points to;</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.get_sref" title="tvm.tir.Schedule.get_sref"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_sref</span></code></a>(rand_var_or_stmt)</p></td>
<td><p>Returns the corresponding sref to the given 1) LoopRV 2) BlockRV 3) Block 4) For</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.remove_rv" title="tvm.tir.Schedule.remove_rv"><code class="xref py py-obj docutils literal notranslate"><span class="pre">remove_rv</span></code></a>(rand_var)</p></td>
<td><p>Remove a random variable from the symbol table</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.sample_categorical" title="tvm.tir.Schedule.sample_categorical"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sample_categorical</span></code></a>(candidates, probs[, decision])</p></td>
<td><p>Sample an integer given the probability distribution</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.get_block" title="tvm.tir.Schedule.get_block"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_block</span></code></a>(name[, func_name])</p></td>
<td><p>Retrieve a block in a specific function with its name</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.get_loops" title="tvm.tir.Schedule.get_loops"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_loops</span></code></a>(block)</p></td>
<td><p>Get the parent loops of the block in its scope, from outer to inner</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.fuse" title="tvm.tir.Schedule.fuse"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fuse</span></code></a>(*loops)</p></td>
<td><p>Fuse a list of consecutive loops into one.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.split" title="tvm.tir.Schedule.split"><code class="xref py py-obj docutils literal notranslate"><span class="pre">split</span></code></a>(loop, factors)</p></td>
<td><p>Split a loop into a list of consecutive loops.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.reorder" title="tvm.tir.Schedule.reorder"><code class="xref py py-obj docutils literal notranslate"><span class="pre">reorder</span></code></a>(*ordered_loops)</p></td>
<td><p>Reorder a list of loops.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.parallel" title="tvm.tir.Schedule.parallel"><code class="xref py py-obj docutils literal notranslate"><span class="pre">parallel</span></code></a>(loop)</p></td>
<td><p>Parallelize the input loop.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.vectorize" title="tvm.tir.Schedule.vectorize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">vectorize</span></code></a>(loop)</p></td>
<td><p>Vectorize the input loop.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.bind" title="tvm.tir.Schedule.bind"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bind</span></code></a>(loop, thread_axis)</p></td>
<td><p>Bind the input loop to the given thread axis.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.unroll" title="tvm.tir.Schedule.unroll"><code class="xref py py-obj docutils literal notranslate"><span class="pre">unroll</span></code></a>(loop)</p></td>
<td><p>Unroll the input loop.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.cache_read" title="tvm.tir.Schedule.cache_read"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cache_read</span></code></a>(block, read_buffer_index, …)</p></td>
<td><p>Create a block that reads a buffer region into a read cache.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.cache_write" title="tvm.tir.Schedule.cache_write"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cache_write</span></code></a>(block, write_buffer_index, …)</p></td>
<td><p>Create a block that reads a buffer region into a write cache.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.compute_at" title="tvm.tir.Schedule.compute_at"><code class="xref py py-obj docutils literal notranslate"><span class="pre">compute_at</span></code></a>(block, loop[, preserve_unit_loops])</p></td>
<td><p>Compute-At.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.reverse_compute_at" title="tvm.tir.Schedule.reverse_compute_at"><code class="xref py py-obj docutils literal notranslate"><span class="pre">reverse_compute_at</span></code></a>(block, loop[, …])</p></td>
<td><p>Reverse-Compute-At.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.compute_inline" title="tvm.tir.Schedule.compute_inline"><code class="xref py py-obj docutils literal notranslate"><span class="pre">compute_inline</span></code></a>(block)</p></td>
<td><p>Inline a block into its consumer(s).</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.reverse_compute_inline" title="tvm.tir.Schedule.reverse_compute_inline"><code class="xref py py-obj docutils literal notranslate"><span class="pre">reverse_compute_inline</span></code></a>(block)</p></td>
<td><p>Inline a block into its only producer.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.decompose_reduction" title="tvm.tir.Schedule.decompose_reduction"><code class="xref py py-obj docutils literal notranslate"><span class="pre">decompose_reduction</span></code></a>(block, loop)</p></td>
<td><p>Decompose a reduction block into two separate blocks.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.rfactor" title="tvm.tir.Schedule.rfactor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rfactor</span></code></a>(loop, factor_axis)</p></td>
<td><p>Factorize an associative reduction block by the specified loop.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.Schedule.storage_align" title="tvm.tir.Schedule.storage_align"><code class="xref py py-obj docutils literal notranslate"><span class="pre">storage_align</span></code></a>(block, buffer_index, axis, …)</p></td>
<td><p>Set alignment requirement for specific dimension such that stride[axis] == k * factor + offset for some k.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.Schedule.enter_postproc" title="tvm.tir.Schedule.enter_postproc"><code class="xref py py-obj docutils literal notranslate"><span class="pre">enter_postproc</span></code></a>()</p></td>
<td><p>A no-op that marks the start of postprocessing phase of scheduling</p></td>
</tr>
</tbody>
</table>
<dl class="py property">
<dt class="sig sig-object py" id="tvm.tir.Schedule.mod">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">mod</span></span><em class="property"><span class="pre">:</span> <span class="pre">tvm.ir.module.IRModule</span></em><a class="headerlink" href="#tvm.tir.Schedule.mod" title="永久链接至目标">¶</a></dt>
<dd><p>Returns the AST of the module being scheduled</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.tir.Schedule.state">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">state</span></span><em class="property"><span class="pre">:</span> <span class="pre">tvm.tir.schedule.state.ScheduleState</span></em><a class="headerlink" href="#tvm.tir.Schedule.state" title="永久链接至目标">¶</a></dt>
<dd><p>Returns the ScheduleState in the current schedule class</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.tir.Schedule.trace">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">trace</span></span><em class="property"><span class="pre">:</span> <span class="pre">Optional[tvm.tir.schedule.trace.Trace]</span></em><a class="headerlink" href="#tvm.tir.Schedule.trace" title="永久链接至目标">¶</a></dt>
<dd><p>Returns the internally maintained trace of scheduling program execution</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.copy">
<span class="sig-name descname"><span class="pre">copy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#tvm.tir.Schedule" title="tvm.tir.schedule.schedule.Schedule"><span class="pre">tvm.tir.schedule.schedule.Schedule</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.copy" title="永久链接至目标">¶</a></dt>
<dd><p>Returns a copy of the schedule, including both the state and the symbol table,
* guaranteeing that
* 1) SRef tree is completely reconstructed;
* 2) The IRModule being scheduled is untouched;
* 3) All the random variables are valid in the copy, pointing to the corresponding sref
* reconstructed</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>copy</strong> – A new copy of the schedule</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="#tvm.tir.Schedule" title="tvm.tir.Schedule">Schedule</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.seed">
<span class="sig-name descname"><span class="pre">seed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.seed" title="永久链接至目标">¶</a></dt>
<dd><p>Seed the randomness</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>seed</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The new random seed, -1 if use device random, otherwise non-negative</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.fork_seed">
<span class="sig-name descname"><span class="pre">fork_seed</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.fork_seed" title="永久链接至目标">¶</a></dt>
<dd><p>Returns a forked random state as seed for new schedules</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>seed</strong> – The forked random state, not the same as the current random state</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.show">
<span class="sig-name descname"><span class="pre">show</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rand_var</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.expr.PrimExpr"><span class="pre">tvm.ir.expr.PrimExpr</span></a><span class="p"><span class="pre">,</span> </span><span class="pre">tvm.tir.schedule.schedule.BlockRV</span><span class="p"><span class="pre">,</span> </span><span class="pre">tvm.tir.schedule.schedule.LoopRV</span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.show" title="永久链接至目标">¶</a></dt>
<dd><p>Returns a string representation of the value that the random variable evaluates to</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>rand_var</strong> (<em>Union</em><em>[</em><em>ExprRV</em><em>, </em><em>BlockRV</em><em>, </em><em>LoopRV</em><em>]</em>) – The random variable to be evaluated</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>str_repr</strong> – The string representation</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.get">
<span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rand_var_or_sref</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.expr.PrimExpr"><span class="pre">tvm.ir.expr.PrimExpr</span></a><span class="p"><span class="pre">,</span> </span><span class="pre">tvm.tir.schedule.schedule.BlockRV</span><span class="p"><span class="pre">,</span> </span><span class="pre">tvm.tir.schedule.schedule.LoopRV</span><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.schedule.block_scope.StmtSRef"><span class="pre">tvm.tir.schedule.block_scope.StmtSRef</span></a><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.stmt.Block"><span class="pre">tvm.tir.stmt.Block</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.For" title="tvm.tir.stmt.For"><span class="pre">tvm.tir.stmt.For</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#tvm.tir.Schedule.get" title="永久链接至目标">¶</a></dt>
<dd><p>Returns:
- the corresponding Block that a BlockRV evaluates to;
- the corresponding For that a LoopRV evaluates to;
- the corresponding integer that a ExprRV evaluates to;
- the corresponding Block that a block sref points to;
- the corresponding For that a loop sref points to;</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>rand_var_or_sref</strong> (<em>Union</em><em>[</em><em>ExprRV</em><em>, </em><em>BlockRV</em><em>, </em><em>LoopRV</em><em>, </em><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.StmtSRef"><em>StmtSRef</em></a><em>]</em>) – The random variable / sref to be evaluated</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The corresponding result</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Optional[Union[<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a>, <a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.Block">Block</a>, <a class="reference internal" href="#tvm.tir.For" title="tvm.tir.For">For</a>]]</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.get_sref">
<span class="sig-name descname"><span class="pre">get_sref</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rand_var_or_stmt</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><span class="pre">tvm.tir.schedule.schedule.BlockRV</span><span class="p"><span class="pre">,</span> </span><span class="pre">tvm.tir.schedule.schedule.LoopRV</span><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.stmt.Block"><span class="pre">tvm.tir.stmt.Block</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.For" title="tvm.tir.stmt.For"><span class="pre">tvm.tir.stmt.For</span></a><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.schedule.block_scope.StmtSRef"><span class="pre">tvm.tir.schedule.block_scope.StmtSRef</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#tvm.tir.Schedule.get_sref" title="永久链接至目标">¶</a></dt>
<dd><p>Returns the corresponding sref to the given
1) LoopRV
2) BlockRV
3) Block
4) For</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>rand_var_or_stmt</strong> (<em>Union</em><em>[</em><em>BlockRV</em><em>, </em><em>LoopRV</em><em>, </em><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.Block"><em>Block</em></a><em>, </em><a class="reference internal" href="#tvm.tir.For" title="tvm.tir.For"><em>For</em></a><em>]</em>) – The random variable / sref to be evaluated</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The corresponding result</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Optional[<a class="reference internal" href="#tvm.tir.StmtSRef" title="tvm.tir.StmtSRef">StmtSRef</a>]</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.remove_rv">
<span class="sig-name descname"><span class="pre">remove_rv</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rand_var</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.expr.PrimExpr"><span class="pre">tvm.ir.expr.PrimExpr</span></a><span class="p"><span class="pre">,</span> </span><span class="pre">tvm.tir.schedule.schedule.BlockRV</span><span class="p"><span class="pre">,</span> </span><span class="pre">tvm.tir.schedule.schedule.LoopRV</span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.remove_rv" title="永久链接至目标">¶</a></dt>
<dd><p>Remove a random variable from the symbol table</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>rand_var</strong> (<em>Union</em><em>[</em><em>BlockRV</em><em>, </em><em>LoopRV</em><em>, </em><em>ExprRV</em><em>]</em>) – The random variable to be removed</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.sample_categorical">
<span class="sig-name descname"><span class="pre">sample_categorical</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">candidates</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">probs</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><span class="pre">float</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">decision</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.expr.PrimExpr"><span class="pre">tvm.ir.expr.PrimExpr</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.sample_categorical" title="永久链接至目标">¶</a></dt>
<dd><p>Sample an integer given the probability distribution</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>candidates</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>]</em>) – The candidates to be sampled from</p></li>
<li><p><strong>probs</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a><em>]</em>) – The probability of each candidate</p></li>
<li><p><strong>decision</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>]</em>) – The sampling decision, if any</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The random variable sampled from candidates</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>ExprRV</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.get_block">
<span class="sig-name descname"><span class="pre">get_block</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">func_name</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">'main'</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></span><a class="headerlink" href="#tvm.tir.Schedule.get_block" title="永久链接至目标">¶</a></dt>
<dd><p>Retrieve a block in a specific function with its name</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name of the block</p></li>
<li><p><strong>func_name</strong> (<em>str = &quot;main&quot;</em>) – The name of the function</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>block</strong> – The block retrieved
IndexError is raised if 0 or multiple blocks exist with the specific name.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>BlockRV</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.get_loops">
<span class="sig-name descname"><span class="pre">get_loops</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">tvm.tir.schedule.schedule.LoopRV</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#tvm.tir.Schedule.get_loops" title="永久链接至目标">¶</a></dt>
<dd><p>Get the parent loops of the block in its scope, from outer to inner</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>block</strong> (<em>BlockRV</em>) – The query block</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>loops</strong> – A list of loops above the given block in its scope, from outer to inner</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[LoopRV]</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.fuse">
<span class="sig-name descname"><span class="pre">fuse</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">loops</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">tvm.tir.schedule.schedule.LoopRV</span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">tvm.tir.schedule.schedule.LoopRV</span></span></span><a class="headerlink" href="#tvm.tir.Schedule.fuse" title="永久链接至目标">¶</a></dt>
<dd><p>Fuse a list of consecutive loops into one. It requires:
1) The loops can’t have annotations or thread bindings.
2) The (i+1)-th loop must be the only child of the i-th loop.
3) All loops must start with 0.
4) The domain of a loop to be fused cannot depend on another loop to be fused.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>*loops</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>LoopRV</em><em>]</em>) – The loops to be fused</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fused_loop</strong> – The new loop after fusion</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>LoopRV</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before applying fuse, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_fuse</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
<p>Create the schedule and do fuse:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_fuse</span><span class="p">)</span>
<span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_loops</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">))</span>
<span class="n">sch</span><span class="o">.</span><span class="n">fuse</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">mod</span><span class="p">[</span><span class="s2">&quot;main&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">script</span><span class="p">())</span>
</pre></div>
</div>
<p>After applying fuse, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_fuse</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="c1"># the 2 loops are fused into 1</span>
    <span class="k">for</span> <span class="n">i_j_fused</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">serial</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">16384</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">tir</span><span class="o">.</span><span class="n">floordiv</span><span class="p">(</span><span class="n">i_j_fused</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">T</span><span class="o">.</span><span class="n">floormod</span><span class="p">(</span><span class="n">i_j_fused</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.split">
<span class="sig-name descname"><span class="pre">split</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">loop</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.LoopRV</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">factors</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.expr.PrimExpr"><span class="pre">tvm.ir.expr.PrimExpr</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">tvm.tir.schedule.schedule.LoopRV</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#tvm.tir.Schedule.split" title="永久链接至目标">¶</a></dt>
<dd><p>Split a loop into a list of consecutive loops. It requires:
1) The loop can’t have annotation or thread binding.
2) The loop must start with 0.
Predicates may be added to ensure the total loop numbers keeps unchanged.
In <cite>factors</cite>, at most one of the factors can be None,
which will be automatically inferred.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loop</strong> (<em>LoopRV</em>) – The loop to be split</p></li>
<li><p><strong>factors</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>Union</em><em>[</em><em>ExprRV</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><em>None</em></a><em>]</em><em>]</em>) – The splitting factors
Potential inputs are:
- None
- ExprRV
- Nonnegative constant integers</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>split_loops</strong> – The new loops after split</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[LoopRV]</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before split, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_split</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
<p>Create the schedule and do split:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_split</span><span class="p">)</span>
<span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_loops</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">))</span>
<span class="n">sch</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">factors</span><span class="o">=</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">64</span><span class="p">])</span>
<span class="k">print</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">mod</span><span class="p">[</span><span class="s2">&quot;main&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">script</span><span class="p">())</span>
</pre></div>
</div>
<p>After applying split, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_split</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="c1"># the original loop is split into 2 loops</span>
    <span class="k">for</span> <span class="n">i0</span><span class="p">,</span> <span class="n">i1</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">64</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="p">((</span><span class="n">i0</span><span class="o">*</span><span class="mi">64</span><span class="p">)</span> <span class="o">+</span> <span class="n">i1</span><span class="p">))</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.reorder">
<span class="sig-name descname"><span class="pre">reorder</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">ordered_loops</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">tvm.tir.schedule.schedule.LoopRV</span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.reorder" title="永久链接至目标">¶</a></dt>
<dd><p>Reorder a list of loops. It doesn’t require the loops to be consecutive.
It requires:
1) The loops are in the same chain. That means: the loops can be ordered to [l_1, l_2, … ,
l_n] where l_i is an ancestor of l_{i+1} and there are only single-branch loops between
l_1 and l_n (which also indicates they are under the same scope).
2) After reordering, the domain of an outer loop cannot depend on any of the inner loops.
3) For every block under the loop nests, its block binding must be affine, and the block
variables must be either data parallel or reduction.
4) No duplicated loops are allowed in the arguments.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>*ordered_loops</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>LoopRV</em><em>]</em>) – The loops in the new order</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before reorder, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_reorder</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
<p>Create the schedule and do reorder:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_reorder</span><span class="p">)</span>
<span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_loops</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">))</span>
<span class="n">sch</span><span class="o">.</span><span class="n">reorder</span><span class="p">(</span><span class="n">j</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">mod</span><span class="p">[</span><span class="s2">&quot;main&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">script</span><span class="p">())</span>
</pre></div>
</div>
<p>After applying reorder, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_reorder</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="c1"># Here j and i are reordered</span>
    <span class="k">for</span> <span class="n">j</span><span class="p">,</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.parallel">
<span class="sig-name descname"><span class="pre">parallel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">loop</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.LoopRV</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.parallel" title="永久链接至目标">¶</a></dt>
<dd><p>Parallelize the input loop. It requires:
1) The scope block that the loop is in should have stage-pipeline property
2) All the blocks under the loop are complete blocks or reduction blocks, and have affine
bindings
3) For each block under the loop, the loop can only be contained in data-parallel block
iters’ bindings</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>loop</strong> (<em>LoopRV</em>) – The loop to be parallelized</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before parallel, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_parallel</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
<p>Create the schedule and do parallel:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_parallel</span><span class="p">)</span>
<span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_loops</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">))</span>
<span class="n">sch</span><span class="o">.</span><span class="n">parallel</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
</pre></div>
</div>
<p>After applying parallel, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_parallel</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">parallel</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">serial</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
            <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
                <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.vectorize">
<span class="sig-name descname"><span class="pre">vectorize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">loop</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.LoopRV</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.vectorize" title="永久链接至目标">¶</a></dt>
<dd><p>Vectorize the input loop. It requires:
1) The scope block that the loop is in should have stage-pipeline property
2) All the blocks under the loop are complete blocks or reduction blocks, and have affine
bindings
3) For each block under the loop, the loop can only be contained in data-parallel block
iters’ bindings</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>loop</strong> (<em>LoopRV</em>) – The loop to be vectorized</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before vectorize, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_vectorize</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
<p>Create the schedule and do vectorize:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_vectorize</span><span class="p">)</span>
<span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_loops</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">))</span>
<span class="n">sch</span><span class="o">.</span><span class="n">vectorize</span><span class="p">(</span><span class="n">j</span><span class="p">)</span>
</pre></div>
</div>
<p>After applying vectorize, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_vectorize</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">serial</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">vectorized</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
            <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
                <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.bind">
<span class="sig-name descname"><span class="pre">bind</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">loop</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.LoopRV</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">thread_axis</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.bind" title="永久链接至目标">¶</a></dt>
<dd><p>Bind the input loop to the given thread axis. It requires:
1) The scope block that the loop is in should have stage-pipeline property
2) All the blocks under the loop are complete blocks or reduction blocks, and have affine
bindings
3) For each block under the loop, if the thread axis starts with “threadIdx`, the loop can
only be contained in data-parallel block iter and reduction block iters’ bindings. Otherwise
the loop can only be contained in data-parallel block iters’ bindings</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loop</strong> (<em>LoopRV</em>) – The loop to be bound to the thread axis</p></li>
<li><p><strong>thread_axis</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The thread axis to be bound to the loop. Possible candidates:
- blockIdx.x/y/z
- threadIdx.x/y/z
- vthread.x/y/z
- vthread (It is a legacy behavior that will be deprecated. Please use <cite>vthread.x/y/z</cite>
instead.)</p></li>
</ul>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before bind, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_bind</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
<p>Create the schedule and do bind:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_bind</span><span class="p">)</span>
<span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_loops</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">))</span>
<span class="n">sch</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="s2">&quot;blockIdx.x&quot;</span><span class="p">)</span>
<span class="n">sch</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">j</span><span class="p">,</span> <span class="s2">&quot;threadIdx.x&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>After applying bind, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_bind</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">thread_binding</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">,</span> <span class="n">thread</span> <span class="o">=</span> <span class="s2">&quot;blockIdx.x&quot;</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">thread_binding</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">,</span> <span class="n">thread</span> <span class="o">=</span> <span class="s2">&quot;threadIdx.x&quot;</span><span class="p">):</span>
            <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
                <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.unroll">
<span class="sig-name descname"><span class="pre">unroll</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">loop</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.LoopRV</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.unroll" title="永久链接至目标">¶</a></dt>
<dd><p>Unroll the input loop. It requires nothing</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>loop</strong> (<em>LoopRV</em>) – The loop to be unrolled</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before unroll, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_unroll</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
            <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
<p>Create the schedule and do unroll:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_unroll</span><span class="p">)</span>
<span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_loops</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">))</span>
<span class="n">sch</span><span class="o">.</span><span class="n">unroll</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
</pre></div>
</div>
<p>After applying unroll, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_unroll</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">unroll</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">serial</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
            <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
                <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.cache_read">
<span class="sig-name descname"><span class="pre">cache_read</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">read_buffer_index</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">storage_scope</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></span><a class="headerlink" href="#tvm.tir.Schedule.cache_read" title="永久链接至目标">¶</a></dt>
<dd><p>Create a block that reads a buffer region into a read cache. It requires:</p>
<ol class="arabic simple">
<li><p>There is at most one block who write the buffer in the scope.</p></li>
<li><p>The scope block have stage-pipeline property.</p></li>
</ol>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>block</strong> (<em>BlockRV</em>) – The consumer block of the target buffer.</p></li>
<li><p><strong>read_buffer_index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The index of the buffer in block’s read region.</p></li>
<li><p><strong>storage_scope</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The target storage scope.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>cached_block</strong> – The block of the cache stage</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>BlockRV</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before cache_read, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_cache_read</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
<p>Create the schedule and cache_read:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_cache_read</span><span class="p">)</span>
<span class="n">block_b</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">)</span>
<span class="n">sch</span><span class="o">.</span><span class="n">cache_read</span><span class="p">(</span><span class="n">block_b</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">&quot;local&quot;</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">mod</span><span class="p">[</span><span class="s2">&quot;main&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">script</span><span class="p">())</span>
</pre></div>
</div>
<p>After applying cache_read, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_cache_read</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">A_local</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">((</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="n">scope</span><span class="o">=</span><span class="s2">&quot;local&quot;</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;A_local&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">A_local</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A_local</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.cache_write">
<span class="sig-name descname"><span class="pre">cache_write</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">write_buffer_index</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">storage_scope</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></span><a class="headerlink" href="#tvm.tir.Schedule.cache_write" title="永久链接至目标">¶</a></dt>
<dd><p>Create a block that reads a buffer region into a write cache. It requires:</p>
<ol class="arabic simple">
<li><p>There is only one block who write the buffer in the scope.</p></li>
<li><p>The scope block have stage-pipeline property.</p></li>
</ol>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>block</strong> (<em>BlockRV</em>) – The producer block of the target buffer.</p></li>
<li><p><strong>write_buffer_index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The index of the buffer in block’s write region.</p></li>
<li><p><strong>storage_scope</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The target storage scope.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>cached_block</strong> – The block of the cache stage</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>BlockRV</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before cache_write, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_cache_write</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
</pre></div>
</div>
<p>Create the schedule and cache_write:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_cache_write</span><span class="p">)</span>
<span class="n">block_b</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">)</span>
<span class="n">sch</span><span class="o">.</span><span class="n">cache_write</span><span class="p">(</span><span class="n">block_b</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">&quot;local&quot;</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">mod</span><span class="p">[</span><span class="s2">&quot;main&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">script</span><span class="p">())</span>
</pre></div>
</div>
<p>After applying cache_write, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_cache_write</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B_local</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">((</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="n">scope</span><span class="o">=</span><span class="s2">&quot;local&quot;</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;A_local&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">B_local</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">B_local</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.compute_at">
<span class="sig-name descname"><span class="pre">compute_at</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">loop</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.LoopRV</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">preserve_unit_loops</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><span class="pre">bool</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.compute_at" title="永久链接至目标">¶</a></dt>
<dd><p>Compute-At. Move a producer block under the specific loop, and regenerate the
loops induced by the block so that the buffer region produced by the producer block could
cover those regions consumed by its consumer blocks under the given loop. It requires:</p>
<ol class="arabic simple">
<li><p><cite>block</cite> and <cite>loop</cite> are under the same scope, <cite>loop</cite> is not the ancestor of <cite>block</cite></p></li>
<li><p>The scope block has stage-pipeline property</p></li>
</ol>
<p>3) The subtree of the scope block, where the given block is in, satisfies the compact
dataflow condition. i.e. all the blocks in the scope block’s subtree must be either
complete block or reduction block</p>
<p>4) The block is not an output block with regard to the scope block, i.e. the buffers written
by the block are allocated under the scope block</p>
<ol class="arabic simple" start="5">
<li><p>All the consumers of the block are under the given loop</p></li>
</ol>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>block</strong> (<em>BlockRV</em>) – The block to be moved</p></li>
<li><p><strong>loop</strong> (<em>LoopRV</em>) – The loop where the block to be moved under</p></li>
<li><p><strong>preserve_unit_loops</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether to keep the trivial loops whose extents are 1</p></li>
</ul>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before compute-at, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_compute_at</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">((</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;C&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">+</span> <span class="mf">1.0</span>
</pre></div>
</div>
<p>Create the schedule and do compute-at:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_compute_at</span><span class="p">)</span>
<span class="n">block</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">)</span>
<span class="n">loop</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_loops</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;C&quot;</span><span class="p">))</span>
<span class="n">sch</span><span class="o">.</span><span class="n">compute_at</span><span class="p">(</span><span class="n">block</span><span class="p">,</span> <span class="n">loop</span><span class="p">,</span> <span class="n">preserve_unit_loops</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">mod</span><span class="p">[</span><span class="s2">&quot;main&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">script</span><span class="p">())</span>
</pre></div>
</div>
<p>After applying compute-at, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_compute_at</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">((</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">serial</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">serial</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
            <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
                <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">serial</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
            <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;C&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
                <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">+</span> <span class="mf">1.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.reverse_compute_at">
<span class="sig-name descname"><span class="pre">reverse_compute_at</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">loop</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.LoopRV</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">preserve_unit_loops</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><span class="pre">bool</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.reverse_compute_at" title="永久链接至目标">¶</a></dt>
<dd><p>Reverse-Compute-At. Move a consumer block under the specific loop, and regenerate the
loops induced by the block so that the buffer region consumed by the consumer block could
cover those regions produced by its producer blocks under the given loop. It requires:</p>
<ol class="arabic simple">
<li><p><cite>block</cite> and <cite>loop</cite> are under the same scope, <cite>loop</cite> is not the ancestor of <cite>block</cite></p></li>
<li><p>The scope block has stage-pipeline property</p></li>
</ol>
<p>3) The subtree of the scope block, where the given block is in, satisfies the compact
dataflow condition. i.e. all the blocks in the scope block’s subtree must be either
complete block or reduction block</p>
<ol class="arabic simple" start="4">
<li><p>All the producers of the block are under the given loop</p></li>
</ol>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>block</strong> (<em>BlockRV</em>) – The block to be moved</p></li>
<li><p><strong>loop</strong> (<em>LoopRV</em>) – The loop where the block to be moved under</p></li>
<li><p><strong>preserve_unit_loops</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether to keep the trivial loops whose extents are 1</p></li>
</ul>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before reverse-compute-at, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_reverse_compute_at</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">((</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;C&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">+</span> <span class="mf">1.0</span>
</pre></div>
</div>
<p>Create the schedule and do reverse-compute-at:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_reverse_compute_at</span><span class="p">)</span>
<span class="n">block</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;C&quot;</span><span class="p">)</span>
<span class="n">loop</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_loops</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">))</span>
<span class="n">sch</span><span class="o">.</span><span class="n">reverse_compute_at</span><span class="p">(</span><span class="n">block</span><span class="p">,</span> <span class="n">loop</span><span class="p">,</span> <span class="n">preserve_unit_loops</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">mod</span><span class="p">[</span><span class="s2">&quot;main&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">script</span><span class="p">())</span>
</pre></div>
</div>
<p>After applying reverse-compute-at, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_reverse_compute_at</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">((</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">serial</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">serial</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
            <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
                <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">T</span><span class="o">.</span><span class="n">serial</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
            <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;C&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vi</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
                <span class="n">T</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">vj</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
                <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">+</span> <span class="mf">1.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.compute_inline">
<span class="sig-name descname"><span class="pre">compute_inline</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.compute_inline" title="永久链接至目标">¶</a></dt>
<dd><p>Inline a block into its consumer(s). It requires:</p>
<ol class="arabic simple">
<li><p>The block is a complete non-root block, which only produces one buffer</p></li>
<li><p>The block must not be the only leaf in the scope.</p></li>
<li><p>The body of the block must be a BufferStore statement in
the form of, <code class="docutils literal notranslate"><span class="pre">A[i,</span> <span class="pre">j,</span> <span class="pre">k,</span> <span class="pre">...]</span> <span class="pre">=</span> <span class="pre">...</span></code> where the indices of
the LHS are all distinct atomic variables, and no variables
other than those indexing variables are allowed in the
statement.</p></li>
</ol>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>block</strong> (<em>BlockRV</em>) – The block to be inlined to its consumer(s)</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before compute-inline, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_inline</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">((</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;C&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">+</span> <span class="mf">1.0</span>
</pre></div>
</div>
<p>Create the schedule and do compute-inline:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_inline</span><span class="p">)</span>
<span class="n">sch</span><span class="o">.</span><span class="n">compute_inline</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">))</span>
<span class="k">print</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">mod</span><span class="p">[</span><span class="s2">&quot;main&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">script</span><span class="p">())</span>
</pre></div>
</div>
<p>After applying compute-inline, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_inline</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;C&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span> <span class="o">+</span> <span class="mf">1.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.reverse_compute_inline">
<span class="sig-name descname"><span class="pre">reverse_compute_inline</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.reverse_compute_inline" title="永久链接至目标">¶</a></dt>
<dd><p>Inline a block into its only producer. It requires:</p>
<ol class="arabic simple">
<li><p>The block is a complete non-root block, which only produces and consumes one buffer</p></li>
<li><p>The block must not be the only leaf in the scope.</p></li>
<li><p>The only producer of the block is a read-after-write producer and a
complete non-root block</p></li>
<li><p>The body of the block must be a BufferStore statement in the form of,
<code class="docutils literal notranslate"><span class="pre">B[f(i,</span> <span class="pre">j,</span> <span class="pre">k,</span> <span class="pre">...)]</span> <span class="pre">=</span> <span class="pre">g(i,</span> <span class="pre">j,</span> <span class="pre">k,</span> <span class="pre">A[i,</span> <span class="pre">j,</span> <span class="pre">k,</span> <span class="pre">...]</span> <span class="pre">...)</span></code> where the
indices of each <cite>BufferLoad</cite> on the RHS are all distinct atomic
variables, and no variables other than those indexing variables are
allowed in the statement.</p></li>
</ol>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>block</strong> (<em>BlockRV</em>) – The block to be inlined to its producer</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before reverse-compute-inline, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_inline</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">((</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;C&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">+</span> <span class="mf">1.0</span>
</pre></div>
</div>
<p>Create the schedule and do reverse-compute-inline:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_inline</span><span class="p">)</span>
<span class="n">sch</span><span class="o">.</span><span class="n">reverse_compute_inline</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;C&quot;</span><span class="p">))</span>
<span class="k">print</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">mod</span><span class="p">[</span><span class="s2">&quot;main&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">script</span><span class="p">())</span>
</pre></div>
</div>
<p>After applying reverse-compute-inline, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_inline</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;C&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span> <span class="o">+</span> <span class="mf">1.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.decompose_reduction">
<span class="sig-name descname"><span class="pre">decompose_reduction</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">loop</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.LoopRV</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></span><a class="headerlink" href="#tvm.tir.Schedule.decompose_reduction" title="永久链接至目标">¶</a></dt>
<dd><p>Decompose a reduction block into two separate blocks.</p>
<ol class="loweralpha simple">
<li><p>The init block, which is translated from the init statement of the reduction block;</p></li>
<li><p>The update block, which is the original block without init statement.</p></li>
</ol>
<p>The init block is inserted right before the given loop.</p>
<p>The schedule primitive requires:</p>
<ol class="arabic simple">
<li><p>The input block is a reduction block.</p></li>
<li><p>The input loop is the ancestor of the block.</p></li>
<li><p>The input loop is not lower than all the loops related to reduce block var.</p></li>
</ol>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>block</strong> (<em>BlockRV</em>) – The reduction block to be decomposed</p></li>
<li><p><strong>loop</strong> (<em>LoopRV</em>) – The loop above which the init block is inserted before.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>init_block</strong> – The init block</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>BlockRV</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before decompose-reduction, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@tvm.script.tir</span>
<span class="k">def</span> <span class="nf">before_decompose</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">ty</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="n">ty</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">[</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">])</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">[</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">])</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">[</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">])</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">tir</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">tir</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">,</span> <span class="n">tir</span><span class="o">.</span><span class="n">reduce_axis</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">)],</span> <span class="s2">&quot;C&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">,</span> <span class="n">vk</span><span class="p">]:</span>
            <span class="k">with</span> <span class="n">tir</span><span class="o">.</span><span class="n">init</span><span class="p">():</span>
                <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span>
            <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">+</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vk</span><span class="p">]</span> <span class="o">*</span> <span class="n">B</span><span class="p">[</span><span class="n">vj</span><span class="p">,</span> <span class="n">vk</span><span class="p">]</span>
</pre></div>
</div>
<p>Create the schedule and do decompose-reduction with specified loop:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_decompose</span><span class="p">)</span>
<span class="n">C</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;C&quot;</span><span class="p">)</span>
<span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_loops</span><span class="p">(</span><span class="n">C</span><span class="p">)</span>
<span class="n">sch</span><span class="o">.</span><span class="n">decompose_reduction</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">tvm</span><span class="o">.</span><span class="n">script</span><span class="o">.</span><span class="n">asscript</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">mod</span><span class="p">[</span><span class="s2">&quot;main&quot;</span><span class="p">]))</span>
</pre></div>
</div>
<p>After applying decompose-reduction, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@tvm.script.tir</span>
<span class="k">def</span> <span class="nf">after_decompose</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">ty</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="n">ty</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">[</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">])</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">[</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">])</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">[</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">])</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">tir</span><span class="o">.</span><span class="n">serial</span><span class="p">(</span><span class="mi">128</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">tir</span><span class="o">.</span><span class="n">serial</span><span class="p">(</span><span class="mi">128</span><span class="p">):</span>
            <span class="k">with</span> <span class="n">tir</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">])</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
                <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">tir</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">):</span>
        <span class="k">with</span> <span class="n">tir</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">,</span> <span class="n">tir</span><span class="o">.</span><span class="n">reduce_axis</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">)],</span> <span class="s2">&quot;C&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">,</span> <span class="n">vk</span><span class="p">]:</span>
            <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">+</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vk</span><span class="p">]</span> <span class="o">*</span> <span class="n">B</span><span class="p">[</span><span class="n">vj</span><span class="p">,</span> <span class="n">vk</span><span class="p">]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.rfactor">
<span class="sig-name descname"><span class="pre">rfactor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">loop</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.LoopRV</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">factor_axis</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">tvm.tir.schedule.schedule.LoopRV</span></span></span><a class="headerlink" href="#tvm.tir.Schedule.rfactor" title="永久链接至目标">¶</a></dt>
<dd><p>Factorize an associative reduction block by the specified loop.</p>
<p>An associative reduction cannot be parallelized directly,
because it leads to potential race condition during accumulation.
Alternatively, the reduction could be factorized on a loop with the following steps:
- Step 1: evenly slice the reduction into <cite>n</cite> separate chunks, where <cite>n</cite> is the loop extent
- Step 2: compute the chunks separately and write the result into <cite>n</cite> intermediate buffers;
- Step 3: accumulate the <cite>n</cite> separate buffer into the result buffer.
Note that the Step 2 above introduces opportunities for parallelization.</p>
<p>RFactor is a schedule primitive that implements the transformation described above:
Given a block that writes to buffer <cite>B</cite>, it factorizes a loop of extent <cite>n</cite>.</p>
<p>For example, the pseudocode below accumulates <cite>B[i] = sum(A[i, : , : ])</cite>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">128</span><span class="p">):</span>                    <span class="c1"># loop i is a data parallel loop</span>
    <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">128</span><span class="p">):</span>                <span class="c1"># loop j is a reduction loop</span>
        <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">128</span><span class="p">):</span>            <span class="c1"># loop k is a reduction loop</span>
            <span class="n">B</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span><span class="p">]</span>
</pre></div>
</div>
<p>Suppose RFactor is applied on the innermost loop <cite>k</cite> and <cite>factor_axis = 1</cite>.
RFactor then creates an intermediate buffer and two blocks.</p>
<p>1. The intermediate buffer, or “rf-buffer” is a buffer of rank <cite>ndim(B) + 1</cite> and
size <cite>size(B) * n</cite>, whose shape expands from <cite>shape(B)</cite> by adding an axis of <cite>n</cite>
at the position specified by <cite>factor_axis</cite>. For example,</p>
<blockquote>
<div><ul class="simple">
<li><p>shape(B) = [1, 2, 3], factor_axis = 0  =&gt; shape(B_rf) = [n, 1, 2, 3]</p></li>
<li><p>shape(B) = [1, 2, 3], factor_axis = 1  =&gt; shape(B_rf) = [1, n, 2, 3]</p></li>
<li><p>shape(B) = [1, 2, 3], factor_axis = 2  =&gt; shape(B_rf) = [1, 2, n, 3]</p></li>
<li><p>shape(B) = [1, 2, 3], factor_axis = 3  =&gt; shape(B_rf) = [1, 2, 3, n]</p></li>
</ul>
</div></blockquote>
<p>2. The rfactor block, or “rf-block”, is a block that writes to the <cite>rf-buffer</cite> without
accumulating over the loop <cite>k</cite>, i.e. the loop <cite>k</cite> is converted from a reduction loop
to a data parallel loop. In our example, the rf-block is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">B_rf</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>     <span class="c1"># the rf-buffer</span>
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">128</span><span class="p">):</span>            <span class="c1"># loop k is converted to a data parallel loop</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">128</span><span class="p">):</span>        <span class="c1"># loop i is a data parallel loop (unchanged)</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">128</span><span class="p">):</span>    <span class="c1"># loop j is a reduction loop (unchanged)</span>
            <span class="n">B_rf</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">B_rf</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">k</span><span class="p">]</span> <span class="o">+</span> <span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span><span class="p">]</span>
</pre></div>
</div>
<p>3. The write-back block, or <cite>wb-block</cite>, is a block that accumulates the rf-buffer into
the result buffer. All the reduction loops are removed except the loop <cite>k</cite> for accumulation.
In our example, the wb-block is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">128</span><span class="p">):</span>            <span class="c1"># loop i is a data parallel loop (unchanged)</span>
                                <span class="c1"># loop j is removed because it is a reduction loop</span>
    <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">128</span><span class="p">):</span>        <span class="c1"># loop k is a reduction loop (unchanged)</span>
        <span class="n">B</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">B_rf</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">k</span><span class="p">]</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loop</strong> (<em>LoopRV</em>) – The loop outside block for which we want to do rfactor</p></li>
<li><p><strong>factor_axis</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The position where the new dimension is placed in the new introduced rfactor buffer</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>rf_block</strong> – The block which computes partial results over each slices (i.e., the first block
as described in the above illustration)</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>BlockRV</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before rfactor, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_rfactor</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,))</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="n">T</span><span class="o">.</span><span class="n">reduce_axis</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">),</span>
                    <span class="n">T</span><span class="o">.</span><span class="n">reduce_axis</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">)],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vii</span><span class="p">,</span> <span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">init</span><span class="p">():</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vii</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span>
        <span class="n">B</span><span class="p">[</span><span class="n">vii</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="n">vii</span><span class="p">]</span> <span class="o">+</span> <span class="n">A</span><span class="p">[</span><span class="n">vii</span><span class="p">,</span> <span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span>
</pre></div>
</div>
<p>Create the schedule and do rfactor:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_rfactor</span><span class="p">)</span>
<span class="n">_</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">k</span> <span class="o">=</span> <span class="n">sch</span><span class="o">.</span><span class="n">get_loops</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">))</span>
<span class="n">sch</span><span class="o">.</span><span class="n">rfactor</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">mod</span><span class="p">[</span><span class="s2">&quot;main&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">script</span><span class="p">())</span>
</pre></div>
</div>
<p>After applying rfactor, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_rfactor</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">[</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">])</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">[</span><span class="mi">128</span><span class="p">])</span>
    <span class="n">B_rf</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">])</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">,</span> <span class="n">T</span><span class="o">.</span><span class="n">reduce_axis</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">)],</span> <span class="s2">&quot;B_rf&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi2</span><span class="p">,</span> <span class="n">vii</span><span class="p">,</span> <span class="n">vi</span><span class="p">]:</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">init</span><span class="p">():</span>
            <span class="n">B_rf</span><span class="p">[</span><span class="n">vi2</span><span class="p">,</span> <span class="n">vii</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span>
        <span class="n">B_rf</span><span class="p">[</span><span class="n">vi2</span><span class="p">,</span> <span class="n">vii</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">B_rf</span><span class="p">[</span><span class="n">vi2</span><span class="p">,</span> <span class="n">vii</span><span class="p">]</span> <span class="o">+</span> <span class="n">A</span><span class="p">[</span><span class="n">vii</span><span class="p">,</span> <span class="n">vi</span><span class="p">,</span> <span class="n">vi2</span><span class="p">])</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="n">T</span><span class="o">.</span><span class="n">reduce_axis</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">)],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vii_1</span><span class="p">,</span> <span class="n">vi2_1</span><span class="p">]:</span>
        <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">init</span><span class="p">():</span>
            <span class="n">B</span><span class="p">[</span><span class="n">vii_1</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span>
        <span class="n">B</span><span class="p">[</span><span class="n">vii_1</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">B</span><span class="p">[</span><span class="n">vii_1</span><span class="p">]</span> <span class="o">+</span> <span class="n">B_rf</span><span class="p">[</span><span class="n">vi2_1</span><span class="p">,</span> <span class="n">vii_1</span><span class="p">])</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>Rfactor requires:
1) <cite>loop</cite> has only one child block, and it is a reduction block;
2) <cite>loop</cite> is a reduction loop, i.e. the loop variable is bound to only reduction variables
in the block binding;
3) <cite>loop</cite> is not parallelized, vectorized, unrolled or bound to any thread axis;
4) The block scope that <cite>loop</cite> is in is a staged-pipeline;
5) The outermost loop outside the reduction block should has the reduction block as its
first child block;
6) The outermost reduction loop should have only one child block;
7) An unary extent loop that is not bound to any reduction or data parallel variables in
the block binding should not appear under some reduction loop;
8) The reduction block should write to only one buffer, and its init and body are both
simple <cite>BufferStore`s, and the pattern is registered as an associative reducer.
The pre-defined patterns include: plus, multiplication, min and max;
9) Each of the loops on top of the block cannot be bound to a data parallel and a
reduction block binding at the same time;
10) `factor_axis</cite> should be in range <cite>[-ndim(B) - 1, ndim(B)]</cite>,
where <cite>B</cite> is the buffer that the reduction block writes to.
Negative indexing is normalized according to numpy convention.</p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.storage_align">
<span class="sig-name descname"><span class="pre">storage_align</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">tvm.tir.schedule.schedule.BlockRV</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">buffer_index</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">axis</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">factor</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">offset</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.storage_align" title="永久链接至目标">¶</a></dt>
<dd><p>Set alignment requirement for specific dimension such that
stride[axis] == k * factor + offset for some k. This is useful to set memory layout for more
friendly memory access pattern. For example, we can set alignment to be factor=2, offset=1
to avoid bank conflict for thread access on higher dimension in GPU shared memory.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>block</strong> (<em>BlockRV</em>) – The producer block of the buffer.</p></li>
<li><p><strong>buffer_index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The index of the buffer in block’s write region.</p></li>
<li><p><strong>axis</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The dimension to be specified for alignment.</p></li>
<li><p><strong>factor</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The factor multiple of alignment.</p></li>
<li><p><strong>offset</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The required offset factor.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Before storage_align, in TensorIR, the IR is:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">before_storage_align</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">((</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;C&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">+</span> <span class="mf">1.0</span>
</pre></div>
</div>
<p>Create the schedule and do storage_align:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sch</span> <span class="o">=</span> <span class="n">tir</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">before_storage_align</span><span class="p">)</span>
<span class="n">sch</span><span class="o">.</span><span class="n">storage_align</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">get_block</span><span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">),</span> <span class="n">buffer_index</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">factor</span><span class="o">=</span><span class="mi">128</span><span class="p">,</span> <span class="n">offset</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">sch</span><span class="o">.</span><span class="n">mod</span><span class="p">[</span><span class="s2">&quot;main&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">script</span><span class="p">())</span>
</pre></div>
</div>
<p>After applying rfactor, the IR becomes:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">after_storage_align</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">((</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">))</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;B&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">T</span><span class="o">.</span><span class="n">block_attr</span><span class="p">({</span><span class="s2">&quot;buffer_dim_align&quot;</span><span class="p">:</span> <span class="p">[[[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">128</span><span class="p">,</span> <span class="mi">1</span><span class="p">]]]})</span>
        <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">*</span> <span class="mf">2.0</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">128</span><span class="p">,</span> <span class="mi">128</span><span class="p">],</span> <span class="s2">&quot;C&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">C</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">+</span> <span class="mf">1.0</span>
</pre></div>
</div>
<p>After lowering passes, buffer B will have strides as [129, 1].</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>Storage_align requires the buffer to be an intermediate buffer defined via <cite>alloc_buffer</cite>.</p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.tir.Schedule.enter_postproc">
<span class="sig-name descname"><span class="pre">enter_postproc</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span><a class="headerlink" href="#tvm.tir.Schedule.enter_postproc" title="永久链接至目标">¶</a></dt>
<dd><p>A no-op that marks the start of postprocessing phase of scheduling</p>
</dd></dl>

</dd></dl>

<dl class="py exception">
<dt class="sig sig-object py" id="tvm.tir.ScheduleError">
<em class="property"><span class="pre">exception</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.</span></span><span class="sig-name descname"><span class="pre">ScheduleError</span></span><a class="headerlink" href="#tvm.tir.ScheduleError" title="永久链接至目标">¶</a></dt>
<dd><p>Error that happens during TensorIR scheduling.</p>
</dd></dl>

</div>
<div class="section" id="module-tvm.tir.transform">
<span id="tvm-tir-transform"></span><h1>tvm.tir.transform<a class="headerlink" href="#module-tvm.tir.transform" title="永久链接至标题">¶</a></h1>
<p>Namespace of all TIR transformations</p>
<p><strong>函数：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.prim_func_pass" title="tvm.tir.transform.prim_func_pass"><code class="xref py py-obj docutils literal notranslate"><span class="pre">prim_func_pass</span></code></a>([pass_func, opt_level, name, …])</p></td>
<td><p>Decorate a function pass.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.Apply" title="tvm.tir.transform.Apply"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Apply</span></code></a>(ftransform)</p></td>
<td><p>Apply ftransform to each function in the Module.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.BF16CastElimination" title="tvm.tir.transform.BF16CastElimination"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BF16CastElimination</span></code></a>()</p></td>
<td><p>Eliminate verbose casting between fp32 and bf16 Checks if the AST has the pattern: castto32(castto16(some_fp32_op(…))) The verbose casting is generated by BF16Promote for multiple bf16 Ops in a row.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.BF16Legalize" title="tvm.tir.transform.BF16Legalize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BF16Legalize</span></code></a>()</p></td>
<td><p>Legalize bf16 typed Ops.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.BF16Promote" title="tvm.tir.transform.BF16Promote"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BF16Promote</span></code></a>()</p></td>
<td><p>Promote bf16 to fp32.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.BF16TypeLowering" title="tvm.tir.transform.BF16TypeLowering"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BF16TypeLowering</span></code></a>()</p></td>
<td><p>Replace all bf16 type with uint16.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.CoProcSync" title="tvm.tir.transform.CoProcSync"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CoProcSync</span></code></a>()</p></td>
<td><p>Detect and insert sync points to co-processor.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.CombineContextCall" title="tvm.tir.transform.CombineContextCall"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CombineContextCall</span></code></a>()</p></td>
<td><p>Combine context calls in the host function.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.CompactBufferAllocation" title="tvm.tir.transform.CompactBufferAllocation"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CompactBufferAllocation</span></code></a>()</p></td>
<td><p>Compact the buffer access region.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.ConvertBlocksToOpaque" title="tvm.tir.transform.ConvertBlocksToOpaque"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ConvertBlocksToOpaque</span></code></a>()</p></td>
<td><p>Substitute all the block vars with the PrimExprs they are bound to, indicated by the corresponding iter_values in BlockRealize, and then convert the blocks into opaque ones by removing all the iter_values in BlockRealize and iter_vars in Block.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.ConvertForLoopsToSerial" title="tvm.tir.transform.ConvertForLoopsToSerial"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ConvertForLoopsToSerial</span></code></a>()</p></td>
<td><p>Convert Parallel For Loops to Serial For Loops.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.DecorateDeviceScope" title="tvm.tir.transform.DecorateDeviceScope"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DecorateDeviceScope</span></code></a>()</p></td>
<td><p>Decorate all the function’s body as device function.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.Filter" title="tvm.tir.transform.Filter"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Filter</span></code></a>(fcond)</p></td>
<td><p>Filter functions by the calling convention attribute.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.FlattenBuffer" title="tvm.tir.transform.FlattenBuffer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FlattenBuffer</span></code></a>()</p></td>
<td><p>Flatten the multi-dimensional BufferLoad and BufferStore to single dimensional Load/Store.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.HoistIfThenElse" title="tvm.tir.transform.HoistIfThenElse"><code class="xref py py-obj docutils literal notranslate"><span class="pre">HoistIfThenElse</span></code></a>([variant])</p></td>
<td><p>Hoist loop-invariant IfThenElse nodes to outside the eligible loops.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.InferFragment" title="tvm.tir.transform.InferFragment"><code class="xref py py-obj docutils literal notranslate"><span class="pre">InferFragment</span></code></a>()</p></td>
<td><p>Infer the TensorCore fragment infomation using tensor intrinsics.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.InjectCopyIntrin" title="tvm.tir.transform.InjectCopyIntrin"><code class="xref py py-obj docutils literal notranslate"><span class="pre">InjectCopyIntrin</span></code></a>(pragma_key, fintrin)</p></td>
<td><p>Inject virtual thread loops.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.InjectDoubleBuffer" title="tvm.tir.transform.InjectDoubleBuffer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">InjectDoubleBuffer</span></code></a>()</p></td>
<td><p>Inject double buffer statements.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.InjectPrefetch" title="tvm.tir.transform.InjectPrefetch"><code class="xref py py-obj docutils literal notranslate"><span class="pre">InjectPrefetch</span></code></a>()</p></td>
<td><p>Inject prefetch instructions into stmt.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.InjectVirtualThread" title="tvm.tir.transform.InjectVirtualThread"><code class="xref py py-obj docutils literal notranslate"><span class="pre">InjectVirtualThread</span></code></a>()</p></td>
<td><p>Inject virtual thread loops.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.InstrumentBoundCheckers" title="tvm.tir.transform.InstrumentBoundCheckers"><code class="xref py py-obj docutils literal notranslate"><span class="pre">InstrumentBoundCheckers</span></code></a>()</p></td>
<td><p>Instruments bound checkers.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.LegalizePackedCalls" title="tvm.tir.transform.LegalizePackedCalls"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LegalizePackedCalls</span></code></a>()</p></td>
<td><p>Legalize packed calls to have its arguments wrapped in TVMValues</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.LiftAttrScope" title="tvm.tir.transform.LiftAttrScope"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LiftAttrScope</span></code></a>(attr_key)</p></td>
<td><p>Lift common attrs with attr_key to outer scope.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.LoopPartition" title="tvm.tir.transform.LoopPartition"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LoopPartition</span></code></a>()</p></td>
<td><p>Inject virtual thread loops.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.LowerCustomDatatypes" title="tvm.tir.transform.LowerCustomDatatypes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LowerCustomDatatypes</span></code></a>()</p></td>
<td><p>Lower custom datatypes.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.LowerDeviceStorageAccessInfo" title="tvm.tir.transform.LowerDeviceStorageAccessInfo"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LowerDeviceStorageAccessInfo</span></code></a>()</p></td>
<td><p>Lower attached storage access information on device.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.LowerInitBlock" title="tvm.tir.transform.LowerInitBlock"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LowerInitBlock</span></code></a>()</p></td>
<td><p>Lower block init stmt into IfThenElse statements.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.LowerIntrin" title="tvm.tir.transform.LowerIntrin"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LowerIntrin</span></code></a>()</p></td>
<td><p>Lower target specific intrinsic calls.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.LowerMatchBuffer" title="tvm.tir.transform.LowerMatchBuffer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LowerMatchBuffer</span></code></a>()</p></td>
<td><p>Remove match buffers inside the block.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.LowerTVMBuiltin" title="tvm.tir.transform.LowerTVMBuiltin"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LowerTVMBuiltin</span></code></a>()</p></td>
<td><p>Lower tvm builtin intrinsics.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.LowerThreadAllreduce" title="tvm.tir.transform.LowerThreadAllreduce"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LowerThreadAllreduce</span></code></a>()</p></td>
<td><p>Lower cross thread alleduce.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.LowerWarpMemory" title="tvm.tir.transform.LowerWarpMemory"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LowerWarpMemory</span></code></a>()</p></td>
<td><p>Lower warp memory access to low-level device related function calls.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.MakePackedAPI" title="tvm.tir.transform.MakePackedAPI"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MakePackedAPI</span></code></a>([num_unpacked_params])</p></td>
<td><p>Transform the PrimFuncs in the module to a packed func API.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.MakeUnpackedAPI" title="tvm.tir.transform.MakeUnpackedAPI"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MakeUnpackedAPI</span></code></a>()</p></td>
<td><p>Transform the PrimFuncs in the module to a C API compatible with internal calls.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.MergeDynamicSharedMemoryAllocations" title="tvm.tir.transform.MergeDynamicSharedMemoryAllocations"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MergeDynamicSharedMemoryAllocations</span></code></a>()</p></td>
<td><p>This pass merges multiple TIR-level dynamic shared memory allocations into one allocation.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.NarrowDataType" title="tvm.tir.transform.NarrowDataType"><code class="xref py py-obj docutils literal notranslate"><span class="pre">NarrowDataType</span></code></a>(target_bits)</p></td>
<td><p>Narrow down PrimExpr datatype in stmt to target_bits.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.PlanAndUpdateBufferAllocationLocation" title="tvm.tir.transform.PlanAndUpdateBufferAllocationLocation"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PlanAndUpdateBufferAllocationLocation</span></code></a>()</p></td>
<td><p>Locate the buffer allocation to the exact position (usually is the lca of buffer access).</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.RemoveNoOp" title="tvm.tir.transform.RemoveNoOp"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RemoveNoOp</span></code></a>()</p></td>
<td><p>Remove No Op from the Stmt.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.RewriteUnsafeSelect" title="tvm.tir.transform.RewriteUnsafeSelect"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RewriteUnsafeSelect</span></code></a>()</p></td>
<td><p>Detect and rewrite unsafe select that contains memory access.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.Simplify" title="tvm.tir.transform.Simplify"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Simplify</span></code></a>()</p></td>
<td><p>Run arithmetic simplifications on the statements and expressions.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.SkipAssert" title="tvm.tir.transform.SkipAssert"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SkipAssert</span></code></a>()</p></td>
<td><p>Skip assert stmt.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.SplitHostDevice" title="tvm.tir.transform.SplitHostDevice"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SplitHostDevice</span></code></a>()</p></td>
<td><p>Split the function into a host function and device functions.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.StorageFlatten" title="tvm.tir.transform.StorageFlatten"><code class="xref py py-obj docutils literal notranslate"><span class="pre">StorageFlatten</span></code></a>(cache_line_size[, …])</p></td>
<td><p>Flatten the multi-dimensional read/write to 1D.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.StorageRewrite" title="tvm.tir.transform.StorageRewrite"><code class="xref py py-obj docutils literal notranslate"><span class="pre">StorageRewrite</span></code></a>()</p></td>
<td><p>Rewrite storage allocation pattern.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.TextureFlatten" title="tvm.tir.transform.TextureFlatten"><code class="xref py py-obj docutils literal notranslate"><span class="pre">TextureFlatten</span></code></a>()</p></td>
<td><p>Flatten the multi-dimensional read/write to 2D.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.ThreadSync" title="tvm.tir.transform.ThreadSync"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ThreadSync</span></code></a>(storage_scope)</p></td>
<td><p>Insert sync between parallel read/write of shared buffers.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.UnifyThreadBinding" title="tvm.tir.transform.UnifyThreadBinding"><code class="xref py py-obj docutils literal notranslate"><span class="pre">UnifyThreadBinding</span></code></a>()</p></td>
<td><p>Unify all the thread bindings for “blockIdx.x/y/z”, “threadIdx.x/y/z”, and “vthread.x/y/z”.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.UnrollLoop" title="tvm.tir.transform.UnrollLoop"><code class="xref py py-obj docutils literal notranslate"><span class="pre">UnrollLoop</span></code></a>()</p></td>
<td><p>Unroll the constant loop marked by unroll.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.VectorizeLoop" title="tvm.tir.transform.VectorizeLoop"><code class="xref py py-obj docutils literal notranslate"><span class="pre">VectorizeLoop</span></code></a>([enable_vectorize])</p></td>
<td><p>Lower vectorization loops.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.transform.VerifyMemory" title="tvm.tir.transform.VerifyMemory"><code class="xref py py-obj docutils literal notranslate"><span class="pre">VerifyMemory</span></code></a>()</p></td>
<td><p>Verify if func contains illegal host side direct memory access.</p></td>
</tr>
</tbody>
</table>
<p><strong>类：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.transform.PrimFuncPass" title="tvm.tir.transform.PrimFuncPass"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PrimFuncPass</span></code></a>()</p></td>
<td><p>A pass that works on each <a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc"><code class="xref py py-func docutils literal notranslate"><span class="pre">tvm.tir.PrimFunc()</span></code></a> in a module.</p></td>
</tr>
</tbody>
</table>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.prim_func_pass">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">prim_func_pass</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pass_func</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">opt_level</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">required</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Callable</span></span></span><a class="headerlink" href="#tvm.tir.transform.prim_func_pass" title="永久链接至目标">¶</a></dt>
<dd><p>Decorate a function pass.</p>
<p>This function returns a callback when pass_func
is provided. Otherwise, it returns the created function pass using the
given optimization function.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>pass_func</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Callable" title="tvm.relay.dataflow_pattern.Callable"><em>Callable</em></a><em>[</em><em>(</em><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc"><em>tvm.tir.PrimFunc</em></a><em>, </em><a class="reference internal" href="ir.html#tvm.ir.IRModule" title="tvm.ir.IRModule"><em>IRModule</em></a><em>, </em><a class="reference internal" href="ir.html#tvm.transform.PassContext" title="tvm.transform.PassContext"><em>PassContext</em></a><em>) </em><em>-&gt; tvm.tir.PrimFunc</em><em>]</em><em>]</em>) – The transformation function or class.</p></li>
<li><p><strong>opt_level</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The optimization level of this module pass.</p></li>
<li><p><strong>name</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – The name of the function pass. The name could be empty. In this case, the
name of the optimization function will be used as the pass name.</p></li>
<li><p><strong>required</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em><em>]</em>) – The list of passes that the function pass is dependent on.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>create_function_pass</strong> – A decorator will be returned if pass_func is not provided,
otherwise return the decorated result.
The returned decorator has two behaviors depending on the input:
A new FunctionPass will be returned when we decorate a pass function.
A new FunctionPass class will be returned when we decorate a class type.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Union[<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Callable" title="tvm.relay.dataflow_pattern.Callable">Callable</a>, <a class="reference internal" href="relay/transform.html#tvm.relay.transform.FunctionPass" title="tvm.relay.transform.FunctionPass">FunctionPass</a>]</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>The following code block decorates a function pass class.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@tvm.tir.transform.prim_func_pass</span><span class="p">(</span><span class="n">opt_level</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">TestReplaceFunc</span><span class="p">:</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">new_func</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">new_func</span> <span class="o">=</span> <span class="n">new_func</span>

    <span class="k">def</span> <span class="nf">transform_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">,</span> <span class="n">mod</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span>
        <span class="c1"># just for demo purposes</span>
        <span class="c1"># transform func to new_func</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">new_func</span>
</pre></div>
</div>
<p>The following code creates a function pass by decorating
a user defined transform function.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@tvm.tir.transform.prim_func_pass</span><span class="p">(</span><span class="n">opt_level</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">transform</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="n">mod</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span>
    <span class="c1"># my transformations here.</span>
    <span class="k">return</span> <span class="n">func</span>

<span class="n">function_pass</span> <span class="o">=</span> <span class="n">transform</span>
<span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">function_pass</span><span class="p">,</span> <span class="n">transform</span><span class="o">.</span><span class="n">FunctionPass</span><span class="p">)</span>
<span class="k">assert</span> <span class="n">function_pass</span><span class="o">.</span><span class="n">info</span><span class="o">.</span><span class="n">opt_level</span> <span class="o">==</span> <span class="mi">2</span>

<span class="c1"># Given a module m, the optimization could be invoked as the following:</span>
<span class="n">updated_mod</span> <span class="o">=</span> <span class="n">function_pass</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>
<span class="c1"># Now constant folding should have been applied to every function in</span>
<span class="c1"># the provided module m. And the updated module will be returned.</span>
</pre></div>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.tir.transform.PrimFuncPass">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">PrimFuncPass</span></span><a class="headerlink" href="#tvm.tir.transform.PrimFuncPass" title="永久链接至目标">¶</a></dt>
<dd><p>A pass that works on each <a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc"><code class="xref py py-func docutils literal notranslate"><span class="pre">tvm.tir.PrimFunc()</span></code></a> in a module. A function
pass class should be created through py:func:<cite>tvm.tir.transform.function_pass</cite>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.Apply">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">Apply</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ftransform</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.Apply" title="永久链接至目标">¶</a></dt>
<dd><p>Apply ftransform to each function in the Module.</p>
<p>This function is a thin wrapper around tvm.tir.transform.prim_func_pass</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>ftransform</strong> (<em>tvm.tir.PrimFunc -&gt; tvm.tir.PrimFunc</em>) – The transformation pass.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.BF16CastElimination">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">BF16CastElimination</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.BF16CastElimination" title="永久链接至目标">¶</a></dt>
<dd><p>Eliminate verbose casting between fp32 and bf16
Checks if the AST has the pattern:
castto32(castto16(some_fp32_op(…)))
The verbose casting is generated by BF16Promote for multiple
bf16 Ops in a row. e.g.:
X[i] + Y[i] + T[i] =&gt;
bf16((float32(bf16((float32(X[i]) + float32(Y[i])))) + float32(T[i])))
After this pass:
bf16(float32(X[i]) + float32(Y[i]) + float32(T[i]))</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.BF16Legalize">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">BF16Legalize</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.BF16Legalize" title="永久链接至目标">¶</a></dt>
<dd><p>Legalize bf16 typed Ops.
Runs BF16Promote, BF16CastElimination and BF16TypeLowering</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.BF16Promote">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">BF16Promote</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.BF16Promote" title="永久链接至目标">¶</a></dt>
<dd><p>Promote bf16 to fp32. Add a cast to fp32
before Ops, then add a cast back to bf16.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.BF16TypeLowering">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">BF16TypeLowering</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.BF16TypeLowering" title="永久链接至目标">¶</a></dt>
<dd><p>Replace all bf16 type with uint16. Also lower the casting
between fp32 and bf16</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.CoProcSync">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">CoProcSync</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.CoProcSync" title="永久链接至目标">¶</a></dt>
<dd><p>Detect and insert sync points to co-processor.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.CombineContextCall">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">CombineContextCall</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.CombineContextCall" title="永久链接至目标">¶</a></dt>
<dd><p>Combine context calls in the host function.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.CompactBufferAllocation">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">CompactBufferAllocation</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.CompactBufferAllocation" title="永久链接至目标">¶</a></dt>
<dd><p>Compact the buffer access region. by removing the buffer regions
that are not accessed, i.e. narrowing the buffer shape and adjust
the access region if necessary.</p>
<p class="rubric">示例</p>
<p>Before narrowing, <code class="docutils literal notranslate"><span class="pre">B</span></code> is a <code class="docutils literal notranslate"><span class="pre">[16,</span> <span class="pre">16]</span></code> buffer, but only a
skinny vector <code class="docutils literal notranslate"><span class="pre">B[i,</span> <span class="pre">0:16]</span></code> is accessed.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">16</span><span class="p">):</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([]):</span>
        <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">(</span><span class="mi">16</span><span class="p">,</span> <span class="mi">16</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">16</span><span class="p">):</span>
            <span class="n">B</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">16</span><span class="p">):</span>
            <span class="n">C</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span>
</pre></div>
</div>
<p>This pass narrows the buffer shape and adjust its accessed region
accordingly.  In this particular case, because only a <code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">*</span> <span class="pre">16</span></code>
vector of <code class="docutils literal notranslate"><span class="pre">B</span></code> is accessed, the pass narrows <code class="docutils literal notranslate"><span class="pre">B</span></code> to shape <code class="docutils literal notranslate"><span class="pre">[1,</span>
<span class="pre">16]</span></code>, and changes the access to <code class="docutils literal notranslate"><span class="pre">B[i,</span> <span class="pre">j]</span></code> to <code class="docutils literal notranslate"><span class="pre">B[0,</span> <span class="pre">j]</span></code>.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">16</span><span class="p">):</span>
    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([]):</span>
        <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">alloc_buffer</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">16</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">16</span><span class="p">):</span>
            <span class="n">B</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">16</span><span class="p">):</span>
            <span class="n">C</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">B</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="n">j</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.ConvertBlocksToOpaque">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">ConvertBlocksToOpaque</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.ConvertBlocksToOpaque" title="永久链接至目标">¶</a></dt>
<dd><p>Substitute all the block vars with the PrimExprs they are bound to, indicated by
the corresponding iter_values in BlockRealize, and then convert the blocks into
opaque ones by removing all the iter_values in BlockRealize and iter_vars in Block.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.ConvertForLoopsToSerial">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">ConvertForLoopsToSerial</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.ConvertForLoopsToSerial" title="永久链接至目标">¶</a></dt>
<dd><p>Convert Parallel For Loops to Serial For Loops.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.DecorateDeviceScope">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">DecorateDeviceScope</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.DecorateDeviceScope" title="永久链接至目标">¶</a></dt>
<dd><p>Decorate all the function’s body as device function.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.Filter">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">Filter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fcond</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.Filter" title="永久链接至目标">¶</a></dt>
<dd><p>Filter functions by the calling convention attribute.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>fcond</strong> (<em>tvm.tir.PrimFunc -&gt; bool</em>) – The condition of the filtering.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.FlattenBuffer">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">FlattenBuffer</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.FlattenBuffer" title="永久链接至目标">¶</a></dt>
<dd><p>Flatten the multi-dimensional BufferLoad and BufferStore
to single dimensional Load/Store. Also remove Block to
ensure that the flattened TIR can not be scheduled again.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.HoistIfThenElse">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">HoistIfThenElse</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">variant</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.HoistIfThenElse" title="永久链接至目标">¶</a></dt>
<dd><p>Hoist loop-invariant IfThenElse nodes to outside the eligible loops.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>variant</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="runtime.html#tvm.runtime.String" title="tvm.runtime.String"><em>String</em></a><em>]</em>) – <p>The variant of the pass.
variant can have any one of following values [“basic”, None(Default)].</p>
<p>The basic variant supports basic hoisting scenarios where it expects
the For &amp; If Nodes are in place consecutively and does not involve
global scope variables or more advanced scenarios.</p>
<p>Default variant supports all hoisting scenarios,i.e., {“Basic” + “Advanced”}
supported with control with PassContext configs like below:</p>
<blockquote>
<div><p>config={“tir.HoistIfThenElse”: {“support_block_scope_hosting”: True}}</p>
</div></blockquote>
</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.InferFragment">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">InferFragment</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.InferFragment" title="永久链接至目标">¶</a></dt>
<dd><p>Infer the TensorCore fragment infomation using tensor intrinsics.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.InjectCopyIntrin">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">InjectCopyIntrin</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pragma_key</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">fintrin</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.InjectCopyIntrin" title="永久链接至目标">¶</a></dt>
<dd><p>Inject virtual thread loops.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>pragma_key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The pragma key for hint of copy.</p></li>
<li><p><strong>fintrin</strong> (<em>function</em>) – The function with signature copyintrin(src, dst, pad_before, pad_after, pad_value)</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.InjectDoubleBuffer">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">InjectDoubleBuffer</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.InjectDoubleBuffer" title="永久链接至目标">¶</a></dt>
<dd><p>Inject double buffer statements.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.InjectPrefetch">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">InjectPrefetch</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.InjectPrefetch" title="永久链接至目标">¶</a></dt>
<dd><p>Inject prefetch instructions into stmt.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.InjectVirtualThread">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">InjectVirtualThread</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.InjectVirtualThread" title="永久链接至目标">¶</a></dt>
<dd><p>Inject virtual thread loops.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.InstrumentBoundCheckers">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">InstrumentBoundCheckers</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.InstrumentBoundCheckers" title="永久链接至目标">¶</a></dt>
<dd><p>Instruments bound checkers.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.LegalizePackedCalls">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">LegalizePackedCalls</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.LegalizePackedCalls" title="永久链接至目标">¶</a></dt>
<dd><p>Legalize packed calls to have its arguments wrapped in TVMValues</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.LiftAttrScope">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">LiftAttrScope</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">attr_key</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.LiftAttrScope" title="永久链接至目标">¶</a></dt>
<dd><p>Lift common attrs with attr_key to outer scope.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>attr_key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The attribute key to be checked.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.LoopPartition">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">LoopPartition</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.LoopPartition" title="永久链接至目标">¶</a></dt>
<dd><p>Inject virtual thread loops.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.LowerCustomDatatypes">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">LowerCustomDatatypes</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.LowerCustomDatatypes" title="永久链接至目标">¶</a></dt>
<dd><p>Lower custom datatypes.</p>
<p>See tvm::datatypes::Registry for more information on adding custom datatypes.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.LowerDeviceStorageAccessInfo">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">LowerDeviceStorageAccessInfo</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.LowerDeviceStorageAccessInfo" title="永久链接至目标">¶</a></dt>
<dd><p>Lower attached storage access information on device.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>Run this pass after all storage access analysis finish.</p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.LowerInitBlock">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">LowerInitBlock</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.LowerInitBlock" title="永久链接至目标">¶</a></dt>
<dd><p>Lower block init stmt into IfThenElse statements.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.LowerIntrin">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">LowerIntrin</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.LowerIntrin" title="永久链接至目标">¶</a></dt>
<dd><p>Lower target specific intrinsic calls.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.LowerMatchBuffer">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">LowerMatchBuffer</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.LowerMatchBuffer" title="永久链接至目标">¶</a></dt>
<dd><p>Remove match buffers inside the block. Also, it will validate the binding.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.LowerTVMBuiltin">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">LowerTVMBuiltin</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.LowerTVMBuiltin" title="永久链接至目标">¶</a></dt>
<dd><p>Lower tvm builtin intrinsics.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.LowerThreadAllreduce">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">LowerThreadAllreduce</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.LowerThreadAllreduce" title="永久链接至目标">¶</a></dt>
<dd><p>Lower cross thread alleduce.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.LowerWarpMemory">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">LowerWarpMemory</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.LowerWarpMemory" title="永久链接至目标">¶</a></dt>
<dd><p>Lower warp memory access to low-level device related function calls.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.MakePackedAPI">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">MakePackedAPI</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">num_unpacked_params</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.MakePackedAPI" title="永久链接至目标">¶</a></dt>
<dd><p>Transform the PrimFuncs in the module to a packed func API.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>num_unpacked_params</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Number of parameters that we hope to directly pass via normal arguments
following the PackedFunc input signature. If it is specified as -1 or it
is less than the number of arguments, the pass will packed arguments still.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.MakeUnpackedAPI">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">MakeUnpackedAPI</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.MakeUnpackedAPI" title="永久链接至目标">¶</a></dt>
<dd><p>Transform the PrimFuncs in the module to a C API compatible with internal calls.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.MergeDynamicSharedMemoryAllocations">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">MergeDynamicSharedMemoryAllocations</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.MergeDynamicSharedMemoryAllocations" title="永久链接至目标">¶</a></dt>
<dd><p>This pass merges multiple TIR-level dynamic shared memory allocations
into one allocation.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.NarrowDataType">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">NarrowDataType</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target_bits</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.NarrowDataType" title="永久链接至目标">¶</a></dt>
<dd><p>Narrow down PrimExpr datatype in stmt to target_bits.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>target_bits</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The target bit configuration.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>Run this pass after StorageFlatten.</p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.PlanAndUpdateBufferAllocationLocation">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">PlanAndUpdateBufferAllocationLocation</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.PlanAndUpdateBufferAllocationLocation" title="永久链接至目标">¶</a></dt>
<dd><p>Locate the buffer allocation to the exact position (usually is
the lca of buffer access). This pass will inject opaque block
with alloc_buffers at the allocation site.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.RemoveNoOp">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">RemoveNoOp</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.RemoveNoOp" title="永久链接至目标">¶</a></dt>
<dd><p>Remove No Op from the Stmt.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.RewriteUnsafeSelect">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">RewriteUnsafeSelect</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.RewriteUnsafeSelect" title="永久链接至目标">¶</a></dt>
<dd><p>Detect and rewrite unsafe select that contains memory access.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.Simplify">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">Simplify</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.Simplify" title="永久链接至目标">¶</a></dt>
<dd><p>Run arithmetic simplifications on the statements and expressions.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.SkipAssert">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">SkipAssert</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.SkipAssert" title="永久链接至目标">¶</a></dt>
<dd><p>Skip assert stmt.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.SplitHostDevice">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">SplitHostDevice</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.SplitHostDevice" title="永久链接至目标">¶</a></dt>
<dd><p>Split the function into a host function and device functions.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.StorageFlatten">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">StorageFlatten</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cache_line_size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">create_bound_attribute</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><span class="pre">bool</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.StorageFlatten" title="永久链接至目标">¶</a></dt>
<dd><p>Flatten the multi-dimensional read/write to 1D.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cache_line_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The size of CPU cache line.</p></li>
<li><p><strong>create_bound_attribute</strong> – Whether to create bound attributes.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.StorageRewrite">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">StorageRewrite</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.StorageRewrite" title="永久链接至目标">¶</a></dt>
<dd><p>Rewrite storage allocation pattern.</p>
<p>Moves the allocation to outer most possible scope.
Trying to share space between allocations to make
a static allocation plan when possible.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.TextureFlatten">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">TextureFlatten</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.TextureFlatten" title="永久链接至目标">¶</a></dt>
<dd><p>Flatten the multi-dimensional read/write to 2D.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.ThreadSync">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">ThreadSync</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">storage_scope</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.ThreadSync" title="永久链接至目标">¶</a></dt>
<dd><p>Insert sync between parallel read/write of shared buffers.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>storage_scope</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The target storage scope.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.UnifyThreadBinding">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">UnifyThreadBinding</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.UnifyThreadBinding" title="永久链接至目标">¶</a></dt>
<dd><p>Unify all the thread bindings for “blockIdx.x/y/z”,
“threadIdx.x/y/z”, and “vthread.x/y/z”. Before the unification,
two vars that are bound to a thread axis (e.g., “threadIdx.x”)
use different IterVars and variables in their AttrStmts. After
the unification, we use a consolidated IterVar and a variable
for them.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p><cite>vthread</cite> is a legacy behavior that will be deprecated, though
thread bindings of <cite>vthread</cite> are still also unified in this
pass. Please use <cite>vthread.x</cite>, <cite>vthread.y</cite> and <cite>vthread.z</cite> instead.</p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.UnrollLoop">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">UnrollLoop</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.UnrollLoop" title="永久链接至目标">¶</a></dt>
<dd><p>Unroll the constant loop marked by unroll.</p>
<p>This pass also automatically attach pragma unroll tag to loops which meets the standard.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.VectorizeLoop">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">VectorizeLoop</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">enable_vectorize</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><span class="pre">bool</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.VectorizeLoop" title="永久链接至目标">¶</a></dt>
<dd><p>Lower vectorization loops.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>enable_vectorize</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether vectorization is enabled.
Will lower to scalar loop when it is turned off.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.transform.VerifyMemory">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.transform.</span></span><span class="sig-name descname"><span class="pre">VerifyMemory</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.transform.VerifyMemory" title="永久链接至目标">¶</a></dt>
<dd><p>Verify if func contains illegal host side direct memory access.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>fpass</strong> – The result pass</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="ir.html#tvm.transform.Pass" title="tvm.transform.Pass">tvm.transform.Pass</a></p>
</dd>
</dl>
</dd></dl>

</div>
<div class="section" id="tvm-tir-analysis">
<h1>tvm.tir.analysis<a class="headerlink" href="#tvm-tir-analysis" title="永久链接至标题">¶</a></h1>
<p>Namespace of all TIR analysis utils.</p>
<p><strong>类：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">Block</span></code>(iter_vars, reads, writes, name_hint, …)</p></td>
<td><p>Block node.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">Buffer</span></code>()</p></td>
<td><p>Symbolic data buffer in TVM.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">BufferRegion</span></code>(buffer, region)</p></td>
<td><p>BufferRegion node.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">Dict</span></code>(*args, **kwds)</p></td>
<td><p></p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">List</span></code>(*args, **kwds)</p></td>
<td><p></p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">PrimExpr</span></code>()</p></td>
<td><p>Base class of all primitive expressions.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">PrimFunc</span></code>(params, body[, ret_type, …])</p></td>
<td><p>A function declaration expression.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">Stmt</span></code>()</p></td>
<td><p>Base class of all the statements.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">Var</span></code>(name, dtype, tvm.ir.type.Type], span)</p></td>
<td><p>Symbolic variable.</p></td>
</tr>
</tbody>
</table>
<p><strong>函数：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">calculate_workspace_bytes</span></code>(func, …)</p></td>
<td><p>Calculate the workspace size in bytes needed by the TIR allocates inside the TIR PrimFunc.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">detect_buffer_access_lca</span></code>(func)</p></td>
<td><p>Detect the lowest common ancestor(LCA) of buffer access, including both high-level access(BufferLoad, BufferStore) and low-level access(Load, Store and opaque access).</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">expr_deep_equal</span></code>(lhs, rhs)</p></td>
<td><p>Deeply compare two nested expressions.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_block_access_region</span></code>(block, buffer_var_map)</p></td>
<td><p>Detect which regions of tensors in this block are read or written to.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_block_read_write_region</span></code>(block, …)</p></td>
<td><p>Auto detect the block read/write region according to its body stmt.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">verify_gpu_code</span></code>(func, constraints)</p></td>
<td><p>Verify if module contains illegal host side direct memory access.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">verify_memory</span></code>(func)</p></td>
<td><p>Verify if func contains illegal host side direct memory access.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">verify_ssa</span></code>(func)</p></td>
<td><p>Verify if the func is in SSA form.</p></td>
</tr>
</tbody>
</table>
<dl class="py class">
<dt class="sig sig-object py">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">Block</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">iter_vars</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.IterVar" title="tvm.tir.expr.IterVar"><span class="pre">tvm.tir.expr.IterVar</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reads</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.stmt.BufferRegion"><span class="pre">tvm.tir.stmt.BufferRegion</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">writes</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.stmt.BufferRegion"><span class="pre">tvm.tir.stmt.BufferRegion</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name_hint</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.stmt.Stmt"><span class="pre">tvm.tir.stmt.Stmt</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">init</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.stmt.Stmt"><span class="pre">tvm.tir.stmt.Stmt</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alloc_buffers</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.buffer.Buffer"><span class="pre">tvm.tir.buffer.Buffer</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">match_buffers</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.MatchBufferRegion" title="tvm.tir.stmt.MatchBufferRegion"><span class="pre">tvm.tir.stmt.MatchBufferRegion</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">annotations</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">Mapping</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="runtime.html#tvm.runtime.Object" title="tvm.runtime.object.Object"><span class="pre">tvm.runtime.object.Object</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.base.Span"><span class="pre">tvm.ir.base.Span</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Block node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>iter_vars</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.tir.IterVar" title="tvm.tir.IterVar"><em>IterVar</em></a><em>]</em>) – The block Variable.</p></li>
<li><p><strong>reads</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.BufferRegion"><em>BufferRegion</em></a><em>]</em>) – The read buffer regions of the block.</p></li>
<li><p><strong>writes</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.BufferRegion"><em>BufferRegion</em></a><em>]</em>) – The write buffer regions of the block.</p></li>
<li><p><strong>name_hint</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – the name_hint of the block.</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The body of the block.</p></li>
<li><p><strong>init</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a><em>]</em>) – The init block of the reduction block</p></li>
<li><p><strong>alloc_buffers</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)"><em>list</em></a><em>[</em><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a><em>]</em><em>]</em>) – The buffer allocations</p></li>
<li><p><strong>match_buffers</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.tir.MatchBufferRegion" title="tvm.tir.MatchBufferRegion"><em>MatchBufferRegion</em></a><em>]</em><em>]</em>) – The subregion buffer match</p></li>
<li><p><strong>annotations</strong> (<em>Optional</em><em>[</em><em>Mapping</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="runtime.html#tvm.runtime.Object" title="tvm.runtime.Object"><em>Object</em></a><em>]</em><em>]</em>) – Additional annotation hints.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this block in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">Buffer</span></span></dt>
<dd><p>Symbolic data buffer in TVM.</p>
<p>Buffer provide a way to represent data layout
specialization of data structure in TVM.</p>
<p>Do not construct directly, use <code class="xref py py-func docutils literal notranslate"><span class="pre">decl_buffer()</span></code> instead.
See the documentation of <code class="xref py py-func docutils literal notranslate"><span class="pre">decl_buffer()</span></code> for more details.</p>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<dl class="simple">
<dt><code class="xref py py-obj docutils literal notranslate"><span class="pre">decl_buffer</span></code></dt><dd><p>Declare a buffer</p>
</dd>
</dl>
</div>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">access_ptr</span></code>(access_mask[, ptr_type, …])</p></td>
<td><p>Get an access pointer to the head of buffer.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">vload</span></code>(begin[, dtype])</p></td>
<td><p>Generate an Expr that loads dtype from begin index.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">vstore</span></code>(begin, value)</p></td>
<td><p>Generate a Stmt that store value into begin index.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">scope</span></code>()</p></td>
<td><p>Return the storage scope associated with this buffer.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">access_ptr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">access_mask</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ptr_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'handle'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">content_lanes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">offset</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Get an access pointer to the head of buffer.</p>
<p>This is the recommended method to get buffer data
ptress when interacting with external functions.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>access_mask</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The access pattern MASK. Indicate whether the
access will read or write to the data content.</p></li>
<li><p><strong>ptr_type</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The data type of the result pointer. Do not specify
unless we want to cast pointer to specific type.</p></li>
<li><p><strong>content_lanes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The number of lanes for the data type. This value
is greater than one for vector types.</p></li>
<li><p><strong>offset</strong> (<em>Expr</em><em>, </em><em>optional</em>) – The offset of pointer. We can use it to offset by
the number of elements from the address of ptr.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">实际案例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Get access ptr for read</span>
<span class="nb">buffer</span><span class="o">.</span><span class="n">access_ptr</span><span class="p">(</span><span class="s2">&quot;r&quot;</span><span class="p">)</span>
<span class="c1"># Get access ptr for read/write with bitmask</span>
<span class="nb">buffer</span><span class="o">.</span><span class="n">access_ptr</span><span class="p">(</span><span class="n">Buffer</span><span class="o">.</span><span class="n">READ</span> <span class="o">|</span> <span class="n">Buffer</span><span class="o">.</span><span class="n">WRITE</span><span class="p">)</span>
<span class="c1"># Get access ptr for read/write with str flag</span>
<span class="nb">buffer</span><span class="o">.</span><span class="n">access_ptr</span><span class="p">(</span><span class="s2">&quot;rw&quot;</span><span class="p">)</span>
<span class="c1"># Get access ptr for read with offset</span>
<span class="nb">buffer</span><span class="o">.</span><span class="n">access_ptr</span><span class="p">(</span><span class="s2">&quot;r&quot;</span><span class="p">,</span> <span class="n">offset</span> <span class="o">=</span> <span class="mi">100</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">vload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">begin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Generate an Expr that loads dtype from begin index.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>begin</strong> (<em>Array of Expr</em>) – The beginning index in unit of Buffer.dtype</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data type to be loaded,
can be vector type which have lanes that is multiple of Buffer.dtype</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>load</strong> – The corresponding load expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">vstore</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">begin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Generate a Stmt that store value into begin index.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>begin</strong> (<em>Array of Expr</em>) – The beginning index in unit of Buffer.dtype</p></li>
<li><p><strong>value</strong> (<em>Expr</em>) – The value to be stored.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>store</strong> – The corresponding store stmt.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt">Stmt</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">scope</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
<dd><p>Return the storage scope associated with this buffer.
:returns: <strong>scope</strong> – The storage scope associated with this buffer.
:rtype: str</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">BufferRegion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">buffer</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.buffer.Buffer"><span class="pre">tvm.tir.buffer.Buffer</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">region</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.Range" title="tvm.ir.expr.Range"><span class="pre">tvm.ir.expr.Range</span></a><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span></dt>
<dd><p>BufferRegion node.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>buffer</strong> (<a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a>) – The buffer of the buffer region</p></li>
<li><p><strong>region</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Range" title="tvm.ir.Range"><em>Range</em></a><em>]</em>) – The region array of the buffer region</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">Dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwds</span></span></em><span class="sig-paren">)</span></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">List</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwds</span></span></em><span class="sig-paren">)</span></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">PrimExpr</span></span></dt>
<dd><p>Base class of all primitive expressions.</p>
<p>PrimExpr is used in the low-level code
optimizations and integer analysis.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">PrimFunc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">params</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ret_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">buffer_map</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>A function declaration expression.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>params</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>Union</em><em>[</em><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>tvm.tir.Var</em></a><em>, </em><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>tvm.tir.Buffer</em></a><em>]</em><em>]</em>) – List of input parameters to the function.</p></li>
<li><p><strong>body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>tvm.tir.Stmt</em></a>) – The body of the function.</p></li>
<li><p><strong>ret_type</strong> (<a class="reference internal" href="ir.html#tvm.ir.Type" title="tvm.ir.Type"><em>tvm.ir.Type</em></a>) – The return type annotation of the function.</p></li>
<li><p><strong>buffer_map</strong> (<a class="reference internal" href="ir.html#tvm.ir.Map" title="tvm.ir.Map"><em>Map</em></a><em>[</em><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>tvm.tir.Var</em></a><em>, </em><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>tvm.tir.Buffer</em></a><em>]</em>) – The buffer binding map.</p></li>
<li><p><strong>attrs</strong> (<em>Optional</em><em>[</em><em>tvm.Attrs</em><em>]</em>) – Attributes of the function, can be None</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">with_body</span></code>(new_body[, span])</p></td>
<td><p>Create a new PrimFunc with the same set signatures but a new body.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">specialize</span></code>(param_map)</p></td>
<td><p>Specialize parameters of PrimFunc</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">script</span></code>([tir_prefix, show_meta])</p></td>
<td><p>Print IRModule into TVMScript</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">with_body</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">new_body</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Create a new PrimFunc with the same set signatures but a new body.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>new_body</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>Stmt</em></a>) – The new body.</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>new_func</strong> – The created new function.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc">PrimFunc</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">specialize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">param_map</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Mapping</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.expr.Var"><span class="pre">tvm.tir.expr.Var</span></a><span class="p"><span class="pre">,</span> </span><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.expr.PrimExpr"><span class="pre">tvm.ir.expr.PrimExpr</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.buffer.Buffer"><span class="pre">tvm.tir.buffer.Buffer</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Specialize parameters of PrimFunc</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>param_map</strong> (<em>Mapping</em><em>[</em><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a><em>, </em><em>Union</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a><em>, </em><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a><em>]</em><em>]</em>) – The mapping from function params to the instance</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>We can define a Meta TIR function with symbolic shape:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">mem_copy</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">m</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">int32</span><span class="p">,</span> <span class="n">n</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">int32</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>

    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">],</span> <span class="s2">&quot;&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span>
</pre></div>
</div>
<p>Then we can make it specialized with given shapes or buffers.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">a</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">n</span> <span class="o">=</span> <span class="n">mem_copy</span><span class="o">.</span><span class="n">params</span>
<span class="n">func</span> <span class="o">=</span> <span class="n">mem_copy</span><span class="o">.</span><span class="n">specialize</span><span class="p">({</span><span class="n">a</span><span class="p">:</span> <span class="n">tir</span><span class="o">.</span><span class="n">decl_buffer</span><span class="p">((</span><span class="mi">16</span><span class="p">,</span> <span class="mi">16</span><span class="p">))})</span>
<span class="c1"># or</span>
<span class="n">func</span> <span class="o">=</span> <span class="n">mem_copy</span><span class="o">.</span><span class="n">specialize</span><span class="p">({</span><span class="n">n</span><span class="p">:</span> <span class="mi">16</span><span class="p">,</span> <span class="n">m</span><span class="p">:</span> <span class="mi">16</span><span class="p">})</span>
</pre></div>
</div>
<p>The specialized function:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@T.prim_func</span>
<span class="k">def</span> <span class="nf">mem_copy_16_16</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">T</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">16</span><span class="p">,</span> <span class="mi">16</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">T</span><span class="o">.</span><span class="n">match_buffer</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="mi">16</span><span class="p">,</span> <span class="mi">16</span><span class="p">),</span> <span class="s2">&quot;float32&quot;</span><span class="p">)</span>

    <span class="k">with</span> <span class="n">T</span><span class="o">.</span><span class="n">block</span><span class="p">([</span><span class="mi">16</span><span class="p">,</span> <span class="mi">16</span><span class="p">],</span> <span class="s2">&quot;&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]:</span>
        <span class="n">B</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="n">vi</span><span class="p">,</span> <span class="n">vj</span><span class="p">]</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>func</strong> – The new function with parameter specialized</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc">PrimFunc</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">script</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tir_prefix</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">'tir'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_meta</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><span class="pre">bool</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></span></dt>
<dd><p>Print IRModule into TVMScript</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tir_prefix</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The tir namespace prefix</p></li>
<li><p><strong>show_meta</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether to show meta information</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>script</strong> – The TVM Script of the PrimFunc</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a></p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">Stmt</span></span></dt>
<dd><p>Base class of all the statements.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">Var</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="ir.html#tvm.ir.Type" title="tvm.ir.type.Type"><span class="pre">tvm.ir.type.Type</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">span</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.base.Span"><span class="pre">tvm.ir.base.Span</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Symbolic variable.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name</p></li>
<li><p><strong>dtype</strong> (<em>Union</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>tvm.irType</em><em>]</em>) – The data type</p></li>
<li><p><strong>span</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="ir.html#tvm.ir.Span" title="tvm.ir.Span"><em>Span</em></a><em>]</em>) – The location of this itervar in the source code.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">calculate_workspace_bytes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.function.PrimFunc"><span class="pre">tvm.tir.function.PrimFunc</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">workspace_byte_alignment</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span></span></dt>
<dd><p>Calculate the workspace size in bytes needed by the TIR allocates inside the TIR
PrimFunc.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>func</strong> (<a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc"><em>tvm.tir.PrimFunc</em></a>) – The function to be detected.</p></li>
<li><p><strong>workspace_byte_alignment</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The byte alignment required for each tensor</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – Workspace size in bytes.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">detect_buffer_access_lca</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.function.PrimFunc"><span class="pre">tvm.tir.function.PrimFunc</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.buffer.Buffer"><span class="pre">tvm.tir.buffer.Buffer</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.stmt.Stmt"><span class="pre">tvm.tir.stmt.Stmt</span></a><span class="p"><span class="pre">]</span></span></span></span></dt>
<dd><p>Detect the lowest common ancestor(LCA) of buffer access, including both high-level
access(BufferLoad, BufferStore) and low-level access(Load, Store and opaque access).
The LCA may be a For loop or a Block.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>func</strong> (<a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc"><em>tvm.tir.PrimFunc</em></a>) – The function to be detected.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – Map from buffer to the LCA of all access to it.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict">Dict</a>[<a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer">Buffer</a>, <a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt">Stmt</a>]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">expr_deep_equal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">lhs</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.expr.PrimExpr"><span class="pre">tvm.ir.expr.PrimExpr</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">rhs</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.expr.PrimExpr"><span class="pre">tvm.ir.expr.PrimExpr</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><span class="pre">bool</span></a></span></span></dt>
<dd><p>Deeply compare two nested expressions.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>lhs</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The left operand.</p></li>
<li><p><strong>rhs</strong> (<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a>) – The right operand.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The comparison result</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)">bool</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>This function does not remap variable bindings, it will not
return true for (let x = 1 in x + 1) vs (let y = 1 in y + 1), unless x.same_as(y).
Use py:func:<cite>tvm.ir.structural_equal</cite> to handle structural variable remapping.</p>
<p>Due to the restriction of not remapping variables, this function can run
faster than StructuralEqual and can be used as a utility function during arithmetic
simplifications.</p>
<p>Always consider py:func:<cite>tvm.ir.structural_equal</cite> first, which handles
the structural remapping.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<p><a class="reference internal" href="ir.html#tvm.ir.structural_equal" title="tvm.ir.structural_equal"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tvm.ir.structural_equal</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">get_block_access_region</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.stmt.Block"><span class="pre">tvm.tir.stmt.Block</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">buffer_var_map</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.expr.Var"><span class="pre">tvm.tir.expr.Var</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.buffer.Buffer"><span class="pre">tvm.tir.buffer.Buffer</span></a><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.stmt.BufferRegion"><span class="pre">tvm.tir.stmt.BufferRegion</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></span></dt>
<dd><dl class="simple">
<dt>Detect which regions of tensors in this block are read or written to.</dt><dd><p>Regions are sorted by order of appearance in the AST.</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>block</strong> (<a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.Block"><em>tvm.tir.Block</em></a>) – The block in which we are detecting read/write regions.</p></li>
<li><p><strong>buffer_var_map</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a><em>, </em><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a><em>]</em>) – The outside buffers which may access the block. Mapping from buffer var to the buffer</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><p><strong>result</strong> –</p>
<dl class="simple">
<dt>Array of access regions. There are three arrays of BufferRegion:</dt><dd><ul class="simple">
<li><p>first: read regions</p></li>
<li><p>second: write regions</p></li>
<li><p>third: opaque regions</p></li>
</ul>
</dd>
</dl>
</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[<a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.BufferRegion">BufferRegion</a>]]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">get_block_read_write_region</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.stmt.Block"><span class="pre">tvm.tir.stmt.Block</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">buffer_var_map</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.expr.Var"><span class="pre">tvm.tir.expr.Var</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.buffer.Buffer"><span class="pre">tvm.tir.buffer.Buffer</span></a><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.stmt.BufferRegion"><span class="pre">tvm.tir.stmt.BufferRegion</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></span></dt>
<dd><dl class="simple">
<dt>Auto detect the block read/write region according to its body stmt.</dt><dd><p>An opaque access will be counted as both a read and a write access</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>block</strong> (<a class="reference internal" href="#tvm.tir.Block" title="tvm.tir.Block"><em>tvm.tir.Block</em></a>) – The block in which we are detecting read/write regions.</p></li>
<li><p><strong>buffer_var_map</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a><em>, </em><a class="reference internal" href="#tvm.tir.Buffer" title="tvm.tir.Buffer"><em>Buffer</em></a><em>]</em>) – The outside buffers which may access the block. Mapping from buffer var to the buffer</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – An array only consisting of the read regions and write regions of the input block</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[<a class="reference internal" href="#tvm.tir.BufferRegion" title="tvm.tir.BufferRegion">BufferRegion</a>]]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">verify_gpu_code</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.function.PrimFunc"><span class="pre">tvm.tir.function.PrimFunc</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">constraints</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span> </span><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><span class="pre">None</span></a></span></span></dt>
<dd><p>Verify if module contains illegal host side direct memory access.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>func</strong> (<a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc"><em>tvm.tir.PrimFunc</em></a>) – The module to be verified.</p></li>
<li><p><strong>constraints</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>]</em>) – The attribute constraints.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The result of verification.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)">bool</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">verify_memory</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.function.PrimFunc"><span class="pre">tvm.tir.function.PrimFunc</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><span class="pre">bool</span></a></span></span></dt>
<dd><p>Verify if func contains illegal host side direct memory access.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>func</strong> (<a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc"><em>tvm.tir.PrimFunc</em></a>) – The module to be verified.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The result of verification.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)">bool</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.analysis.</span></span><span class="sig-name descname"><span class="pre">verify_ssa</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.function.PrimFunc"><span class="pre">tvm.tir.function.PrimFunc</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><span class="pre">bool</span></a></span></span></dt>
<dd><p>Verify if the func is in SSA form.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>func</strong> (<a class="reference internal" href="#tvm.tir.PrimFunc" title="tvm.tir.PrimFunc"><em>tvm.tir.PrimFunc</em></a>) – The module to be verified.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The result of verification.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)">bool</a></p>
</dd>
</dl>
</dd></dl>

</div>
<div class="section" id="module-tvm.tir.stmt_functor">
<span id="tvm-tir-stmt-functor"></span><h1>tvm.tir.stmt_functor<a class="headerlink" href="#module-tvm.tir.stmt_functor" title="永久链接至标题">¶</a></h1>
<p>Statement functor utilities for IR transformations</p>
<p><strong>函数：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.stmt_functor.ir_transform" title="tvm.tir.stmt_functor.ir_transform"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ir_transform</span></code></a>(stmt, preorder, postorder[, …])</p></td>
<td><p>Recursively visit and transform ir nodes in post DFS order.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.tir.stmt_functor.post_order_visit" title="tvm.tir.stmt_functor.post_order_visit"><code class="xref py py-obj docutils literal notranslate"><span class="pre">post_order_visit</span></code></a>(stmt, fvisit)</p></td>
<td><p>Recursively visit the ir in post DFS order node, apply fvisit</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.tir.stmt_functor.substitute" title="tvm.tir.stmt_functor.substitute"><code class="xref py py-obj docutils literal notranslate"><span class="pre">substitute</span></code></a>(node, vmap)</p></td>
<td><p>Substitute the var specified by vmap.</p></td>
</tr>
</tbody>
</table>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.stmt_functor.ir_transform">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.stmt_functor.</span></span><span class="sig-name descname"><span class="pre">ir_transform</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stmt</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">preorder</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">postorder</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">only_enable</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.stmt_functor.ir_transform" title="永久链接至目标">¶</a></dt>
<dd><p>Recursively visit and transform ir nodes in post DFS order.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>stmt</strong> (<a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt"><em>tvm.tir.Stmt</em></a>) – The input to be transformed.</p></li>
<li><p><strong>preorder</strong> (<em>function</em>) – The function called in before recursive mutation
If preorder returns None, then the transform will proceed to recursive call.
If preorder returns a not None tvm.tir.Stmt/Expr, the transformer will simply return it and
won’t do further recursion.</p></li>
<li><p><strong>postorder</strong> (<em>function</em>) – The function called after recursive mutation.</p></li>
<li><p><strong>only_enable</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em><em>]</em>) – List of types that we only enable.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt">tvm.tir.Stmt</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.stmt_functor.post_order_visit">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.stmt_functor.</span></span><span class="sig-name descname"><span class="pre">post_order_visit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stmt</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fvisit</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.stmt_functor.post_order_visit" title="永久链接至目标">¶</a></dt>
<dd><dl class="simple">
<dt>Recursively visit the ir in post DFS order node, apply fvisit</dt><dd><p>Each node is guaranteed to be visited only once.</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>fvisit</strong> (<em>function</em>) – The visitor function.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.tir.stmt_functor.substitute">
<span class="sig-prename descclassname"><span class="pre">tvm.tir.stmt_functor.</span></span><span class="sig-name descname"><span class="pre">substitute</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">node</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmap</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.tir.stmt_functor.substitute" title="永久链接至目标">¶</a></dt>
<dd><p>Substitute the var specified by vmap.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>node</strong> (<em>ObjectRef</em>) – The input.</p></li>
<li><p><strong>vmap</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference internal" href="#tvm.tir.Var" title="tvm.tir.Var"><em>Var</em></a><em>, </em><a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr"><em>PrimExpr</em></a><em>]</em>) – The variable mapping.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.tir.Stmt" title="tvm.tir.Stmt">tvm.tir.Stmt</a></p>
</dd>
</dl>
</dd></dl>

</div>


           </div>
           
          </div>
          

<footer>

    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="te.html" class="btn btn-neutral float-right" title="tvm.te" accesskey="n" rel="next">下一个 <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="target.html" class="btn btn-neutral float-left" title="tvm.target" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> 上一个</a>
      
    </div>

<div id="button" class="backtop"><img src="../../../_static//img/right.svg" alt="backtop"/> </div>
<section class="footerSec">
    <div class="footerHeader">
      <ul class="d-flex align-md-items-center justify-content-between flex-column flex-md-row">
        <li class="copywrite d-flex align-items-center">
          <h5 id="copy-right-info">© 2020 Apache Software Foundation | All right reserved</h5>
        </li>
      </ul>

    </div>

    <ul>
      <li class="footernote">Copyright © 2020 The Apache Software Foundation. Apache TVM, Apache, the Apache feather, and the Apache TVM project logo are either trademarks or registered trademarks of the Apache Software Foundation.</li>
    </ul>

</section>
</footer>
        </div>
      </div>

    </section>

  </div>
  

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

  </body>
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    <!-- Theme Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-75982049-2', 'auto');
    ga('send', 'pageview');
    </script>

    
   

</body>
</html>